:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f9f9f7; /* Page plane */
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #0b0b0b;
}

.viz-root {
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --muted:          #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --w1:             #2a78d6;
  --w2:             #eb6834;
  --w3:             #1baf7a;

  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* --- Account-Leiste (eingeloggt als ... / Passwort ändern / Abmelden) --- */

.account-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.account-link {
  color: var(--w1);
  text-decoration: none;
  font-weight: 500;
}

.account-link:hover {
  text-decoration: underline;
}

/* --- Login / Einrichtungs-Seiten --- */

.auth-root {
  max-width: 380px;
  padding-top: 64px;
}

.auth-card {
  text-align: left;
}

.auth-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.auth-subtitle {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-submit {
  margin-top: 4px;
  width: 100%;
}

.auth-footer {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.subtitle {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Messreihen-Auswahl --- */

.dataset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--grid);
}

.dataset-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dataset-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.dataset-select {
  border: 1px solid var(--baseline);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  max-width: 220px;
}

.new-dataset-toggle summary {
  cursor: pointer;
  list-style: none;
}

.new-dataset-toggle summary::-webkit-details-marker {
  display: none;
}

.new-dataset-toggle summary::before {
  content: none;
}

.new-dataset-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.new-dataset-form input[type="text"] {
  border: 1px solid var(--baseline);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  flex: 1;
  min-width: 140px;
}

.new-dataset-form input[type="text"]:focus,
.dataset-select:focus {
  outline: 2px solid var(--w1);
  outline-offset: 1px;
}

.chart-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.btn-ghost {
  border: 1px solid var(--baseline);
  background: #fff;
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  height: fit-content;
  white-space: nowrap;
}

.btn-ghost:hover {
  background: var(--grid);
}

/* --- Zeitraum-Schieberegler direkt unter dem Diagramm --- */

.range-slider-outer {
  margin-top: 4px;
  padding-top: 14px;
}

.range-labels {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.range-label-sep {
  color: var(--muted);
}

.range-reset-btn {
  margin-left: auto;
}

.range-slider-wrap {
  position: relative;
  height: 28px;
  min-width: 80px;
}

.range-slider-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--grid);
  border-radius: 2px;
  transform: translateY(-50%);
}

.range-slider-highlight {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--w1);
  border-radius: 2px;
  opacity: 0.35;
}

.range-slider {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.range-slider:focus {
  outline: none;
}

.range-slider::-webkit-slider-runnable-track {
  background: transparent;
  height: 4px;
}

.range-slider::-moz-range-track {
  background: transparent;
  height: 4px;
}

.range-slider::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--w1);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--baseline);
  cursor: grab;
}

.range-slider::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--w1);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--baseline);
  cursor: grab;
}

.range-slider:active::-webkit-slider-thumb {
  cursor: grabbing;
}

.range-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.35);
}

.range-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-item i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-wrap {
  position: relative;
  height: 380px;
}

.table-toggle {
  margin-top: 16px;
  border-top: 1px solid var(--grid);
  padding-top: 12px;
}

.table-toggle summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.table-scroll {
  max-height: 320px;
  overflow: auto;
  margin-top: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.data-table th {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: normal;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.field .hint {
  color: var(--muted);
  font-weight: 400;
}

.field input {
  border: 1px solid var(--baseline);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
}

.field input:focus {
  outline: 2px solid var(--w1);
  outline-offset: 1px;
}

.field-submit {
  justify-content: flex-end;
}

button {
  background: var(--w1);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #256abf;
}

.banner {
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

.banner p {
  margin: 4px 0;
}

.banner-success {
  background: #e7f6e7;
  color: #006300;
  border: 1px solid rgba(12, 163, 12, 0.25);
}

.banner-error {
  background: #fbe9e8;
  color: #9a1f1f;
  border: 1px solid rgba(211, 59, 59, 0.25);
}

/* --- Größere, leichter zu treffende Slider-Griffe auf Touch-Geräten --- */
@media (pointer: coarse) {
  .range-slider::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    margin-top: -9px;
  }
  .range-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }
  .range-slider,
  .range-slider-wrap {
    height: 32px;
  }
}

@media (max-width: 640px) {
  .viz-root {
    padding: 16px 12px 48px;
  }
  .auth-root {
    padding-top: 32px;
  }
  .card {
    padding: 16px;
    border-radius: 10px;
  }
  .page-header h1 {
    font-size: 19px;
  }
  .subtitle {
    font-size: 13px;
  }
  .entry-form {
    grid-template-columns: 1fr 1fr;
  }
  .field-submit {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .field-submit button {
    width: 100%;
  }
  .chart-wrap {
    height: 300px;
  }
  .dataset-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .dataset-select-wrap {
    justify-content: space-between;
  }
  .dataset-select {
    max-width: none;
    flex: 1;
  }
  .new-dataset-toggle {
    width: 100%;
  }
  .new-dataset-toggle summary.btn-ghost {
    width: 100%;
    text-align: center;
  }
  .range-labels {
    flex-wrap: wrap;
  }
  .legend {
    gap: 10px 14px;
  }
  .table-scroll {
    overflow-x: auto;
  }
  .data-table {
    min-width: 420px;
  }
}

@media (max-width: 420px) {
  .entry-form {
    grid-template-columns: 1fr;
  }
  .chart-wrap {
    height: 260px;
  }
  .card h2 {
    font-size: 15px;
  }
  button {
    padding: 11px 16px;
  }
}
