  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  html {
    overflow-y: scroll;
    scrollbar-gutter: stable;
    background: #f0f2f5;
  }

  body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    color: #1a1a1a;
    padding: 0.5rem 0.88rem 0.08rem;
    min-height: 100vh;
    width: min(128rem, 100%);
    margin-inline: auto;
  }

  header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.64rem;
    margin-bottom: 0.34rem;
  }
  h1     { font-size: 1.24rem; font-weight: 600; }
  .meta  { font-size: 0.73rem; color: #666; margin-top: 0.01rem; }
  .meta.is-stale { color: #9f3a00; font-weight: 600; }
  .site-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    padding: 0.16rem;
    border: 1px solid #d8dde3;
    border-radius: 8px;
    background: rgba(255,255,255,0.86);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
  }
  .site-nav a {
    display: inline-grid;
    place-items: center;
    width: 1.72rem;
    height: 1.72rem;
    border-radius: 6px;
    color: #3f4b59;
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
  }
  /* The sun-behind-cloud glyph sits in a roomier em box than the other
     icons, so it needs a nudge to read at the same visual size. The
     1.72rem cell is fixed, so this cannot shift the layout. */
  .site-nav a[href="/klima/"] { font-size: 1.16rem; }
  .site-nav a:hover { background: #eef2f5; }
  .site-nav a.active {
    background: #457b9d;
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  }
  .header-actions { display: inline-flex; align-items: center; gap: .38rem; margin-left: auto; }
  .share-view {
    display: inline-flex;
    align-items: center;
    height: 1.72rem;
    padding: 0 .55rem;
    border: 1px solid #d8dde3;
    border-radius: 7px;
    background: rgba(255,255,255,0.86);
    color: #3f4b59;
    font: inherit;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
  }
  .share-view:hover { background: #eef2f5; }

  .filter {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    column-gap: 0.8rem;
    row-gap: 0.46rem;
    margin-bottom: 0.52rem;
    background: #fff;
    border-radius: 8px;
    padding: 0.38rem 0.7rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
    font-size: 0.84rem;
  }
  .filter label { color: #555; }
  .time-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.42rem;
  }
  .range-buttons {
    display: inline-flex;
    gap: 0.32rem;
    align-items: center;
    margin-left: 1.05rem;
  }
  .control-spacer {
    width: 0.7rem;
    height: 1.4rem;
    border-left: 1px solid #dde2e7;
    margin-left: 0.12rem;
  }
  .date-field {
    position: relative;
    display: inline-flex;
    align-items: center;
  }
  .date-display {
    width: 8.1rem;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    padding: 0.24rem 2.35rem 0.24rem 0.45rem;
    font-size: 0.84rem;
    font-family: inherit;
  }
  .date-display:focus {
    outline: 2px solid #457b9d;
    border-color: transparent;
  }
  .picker-btn {
    position: absolute;
    right: 0.18rem;
    top: 50%;
    transform: translateY(-50%);
    min-width: 1.9rem;
    padding: 0.14rem 0.32rem;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #f5f5f5;
    font-size: 0.72rem;
    cursor: pointer;
  }
  .picker-btn:hover { background: #e8e8e8; }
  .native-date-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }
  .nav-btn {
    min-width: 2.05rem;
    padding: 0.24rem 0.52rem;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    background: #f5f5f5;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
  }
  .nav-btn:hover:not(:disabled) { background: #e8e8e8; }
  .nav-btn:disabled {
    opacity: 0.45;
    cursor: default;
  }
  .filter-actions {
    display: flex;
    column-gap: 0.92rem;
    align-items: center;
  }
  .toggle-option {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #555;
    font-size: 0.78rem;
    white-space: nowrap;
  }
  .toggle-option input {
    accent-color: #457b9d;
    cursor: pointer;
    width: 0.9rem;
    height: 0.9rem;
    margin: 0;
  }
  .radio-group {
    display: inline-flex;
    gap: 0.18rem;
    align-items: center;
    padding: 0.08rem 0.46rem;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: rgba(255,255,255,0.6);
  }
  /* Marks a control that replaces the whole chart with a distinct view (cf. Klima's
     "Kachelansicht" map-mode control) so it doesn't read as an ordinary overlay toggle. */
  .radio-group-accent {
    border-color: #9dbcce;
    background: #eaf3f8;
  }
  .radio-group-accent .toggle-option {
    color: #2f5770;
    font-weight: 700;
  }
  .data-toggles-start {
    margin-left: 2.3rem;
  }
  .radio-group .toggle-option {
    padding: 0.06rem 0.2rem;
    border-radius: 4px;
  }
  .filter button {
    padding: 0.24rem 0.66rem;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    background: #f5f5f5;
    font-size: 0.81rem;
    cursor: pointer;
  }
  .filter button:hover:not(:disabled) { background: #e8e8e8; }
  .filter button.active { border-color: #888; background: #888; color: #fff; }
  .filter button:disabled { opacity: 0.4; cursor: default; }

  .stats-panel {
    padding: 0.28rem 0.52rem 0.5rem;
    border: 1px solid #e0ded5;
    border-radius: 8px;
    background: #fff;
    margin-bottom: 0.38rem;
  }
  .stats-panel-title {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    margin: -0.1rem 0 0.24rem;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 700;
  }
  .stats-collapse-btn {
    border: 0;
    background: transparent;
    color: #55606d;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
  }
  .stats-collapse-btn:hover { color: #222831; }
  .stats-panel.collapsed {
    padding-bottom: 0.32rem;
    margin-bottom: 0.32rem;
  }
  .stats-panel.collapsed .stats-panel-title { margin-bottom: 0; }
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
  }
  .stats-grid[hidden] { display: none; }
  .daily-profile-title {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
  }
  .daily-profile-collapse-btn {
    border: 0;
    background: transparent;
    color: #55606d;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
  }
  .daily-profile-collapse-btn:hover { color: #222831; }
  .daily-profile-main[hidden] { display: none; }
  #daily-profile-card.collapsed { padding-bottom: 0.38rem; }
  .event-explorer { margin-top: 0.38rem; }
  .event-explorer-title { display: inline-flex; align-items: center; gap: 0.28rem; }
  .event-explorer-toggle { border: 0; background: transparent; color: #55606d; font: inherit; font-size: 0.78rem; line-height: 1; padding: 0; cursor: pointer; }
  .event-explorer-toggle:hover { color: #222831; }
  .event-explorer-note { margin: 0 0 0.42rem; color: #697586; font-size: 0.71rem; line-height: 1.35; }
  .event-explorer-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
  .event-explorer-table th { color: #6a7684; font-size: 0.64rem; font-weight: 650; letter-spacing: .025em; text-align: left; text-transform: uppercase; }
  .event-explorer-table th, .event-explorer-table td { padding: 0.32rem 0.38rem; border-top: 1px solid #e9ebee; vertical-align: top; }
  .event-explorer-table td:nth-child(n+3), .event-explorer-table th:nth-child(n+3) { text-align: right; }
  .event-explorer-table td { color: #364152; }
  @media (max-width: 680px) {
    .event-explorer-table th:nth-child(5), .event-explorer-table td:nth-child(5) { display: none; }
  }
  .stat-card {
    min-width: 0;
    padding: 0.42rem 0.66rem;
    border: 1px solid #e6e8eb;
    border-radius: 9px;
    background: linear-gradient(180deg, #fbfcfd, #f6f7f9);
  }
  .stat-card[title] { cursor: help; }
  .daily-profile-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .daily-profile-tile {
    border: 1px solid #e6e8eb;
    border-radius: 8px;
    padding: 0.4rem 0.45rem 0.3rem;
    background: #fafbfc;
  }
  .daily-profile-tile-title { font-size: 0.8rem; font-weight: 600; color: #334155; display: flex; justify-content: space-between; align-items: baseline; }
  .daily-profile-tile-days { font-size: 0.66rem; font-weight: 500; color: #7a8694; }
  .daily-profile-tile-empty { font-size: 0.72rem; color: #7a8694; padding: 1.6rem 0; text-align: center; }
  .daily-profile-svg { width: 100%; height: auto; margin-top: 0.2rem; cursor: default; }
  .daily-profile-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.18rem 0.28rem;
    margin-top: 0.22rem;
    color: #657080;
    font-size: 0.64rem;
    line-height: 1.25;
  }
  .daily-profile-facts span {
    padding: 0.05rem 0.24rem;
    border-radius: 999px;
    background: #eef1f4;
    white-space: nowrap;
  }
  .daily-profile-axis-label, .daily-profile-svg text { font-size: 7.4px; fill: #748091; }
  .daily-profile-axis-title { font-size: 7.2px; fill: #667383; font-weight: 600; }
  .dp-y-title { letter-spacing: 0.02em; }
  .dp-x-title { font-size: 5.3px; fill: #6f7b8a; font-weight: 500; }
  .daily-profile-grid-line { stroke: #e9ebee; stroke-width: 0.6; }
  .daily-profile-legend { display: flex; justify-content: center; gap: 1.4rem; font-size: 0.74rem; color: #55606d; margin: 0.5rem 0 0.15rem; }
  .daily-profile-legend span { display: inline-flex; align-items: center; }
  .dp-swatch { display: inline-block; width: 0.62rem; height: 0.62rem; border-radius: 2px; margin-right: 0.32rem; vertical-align: middle; }
  /* dashed-line marker for the Verbrauch (Last) line in the Jahresverlauf legend/tooltip */
  .dp-swatch-load { border-radius: 0; height: 0; border-top: 2px dashed #15151a; }
  #daily-profile { position: relative; }
  .dp-tip {
    position: absolute; z-index: 5; pointer-events: none;
    background: rgba(30,34,40,0.96); color: #f2f2ee; font-size: 0.72rem;
    padding: 0.3rem 0.5rem; border-radius: 6px; white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0,0,0,.3); line-height: 1.35;
  }
  .dp-tip strong { font-size: 0.74rem; }
  .daily-profile-note { font-size: 0.7rem; color: #6a7684; margin: 0.5rem 0 0; }
  .dp-mix { margin-top: 0.9rem; border-top: 1px solid #eceef1; padding-top: 0.7rem; }
  .dp-sub-title { font-size: 0.78rem; font-weight: 700; color: #55606d; margin-bottom: 0.4rem; }
  .dp-mix-cols { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.4rem; align-items: start; padding-right: 0.4rem; }
  .dp-mix-stats-box { background: #f7f8fa; border: 1px solid #e9ebee; border-radius: 8px; padding: 0.5rem 0.7rem; }
  .dp-bar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.34rem; }
  .dp-bar-label { flex: 0 0 4.2rem; font-size: 0.74rem; color: #55606d; }
  .dp-bar { flex: 1; display: flex; height: 0.85rem; border-radius: 3px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.05); }
  .dp-seg { height: 100%; }
  .dp-stat { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.76rem; padding: 0.2rem 0; border-bottom: 1px solid #eceef1; }
  .dp-stat[title] { cursor: help; }
  .dp-stat:last-child { border-bottom: none; }
  .dp-stat span { color: #6a7684; }
  .dp-stat strong { color: #2c3440; font-weight: 600; text-align: right; }
  .dp-mix-yearly { margin-top: 0.9rem; }
  .dp-yearly-svg { width: 100%; height: auto; cursor: default; }
  .dp-src-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.15rem 0.9rem; margin-top: 0.7rem; font-size: 0.68rem; color: #55606d; }
  .dp-src-item { display: inline-flex; align-items: center; }
  @media (max-width: 720px) { .dp-mix-cols { grid-template-columns: 1fr; } }
  @media (max-width: 880px) {
    .daily-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  .toggle-option.control-disabled { opacity: 0.42; }

  .stat-value-sub { font-size: 0.56em; font-weight: 500; color: #6a7684; margin-left: 0.45rem; white-space: nowrap; }
  .stat-label {
    display: block;
    margin-bottom: 0.22rem;
    color: #666;
    font-size: 0.69rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .stat-value {
    display: block;
    font-size: 0.98rem;
    font-weight: 700;
    color: #20242a;
    line-height: 1.15;
  }
  .stat-note {
    display: block;
    margin-top: 0.18rem;
    color: #667085;
    font-size: 0.72rem;
    line-height: 1.25;
  }
  .stat-note-grid {
    display: inline-grid;
    grid-template-columns: max-content max-content max-content;
    column-gap: 0.42rem;
    row-gap: 0.06rem;
    align-items: baseline;
    margin-top: 0.04rem;
  }
  .stat-note-grid-value {
    color: #536174;
    font-variant-numeric: tabular-nums;
  }

  @media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  @media (max-width: 880px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 680px) {
    header { align-items: center; }
    .filter { align-items: flex-start; }
    .filter-actions {
      flex-wrap: wrap;
      row-gap: 0.38rem;
      column-gap: 0.55rem;
    }
    .data-toggles-start {
      margin-left: 0;
      margin-right: 0;
      padding-left: 0;
    }
    .radio-group { flex-wrap: wrap; }
    .stats-grid { grid-template-columns: 1fr; }
  }

  .card {
    background: #fff;
    border-radius: 10px;
    padding: 0.5rem 0.9rem 0.45rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
  }
  #chart-card { padding-top: 0.42rem; padding-bottom: 0.36rem; }
  .card h2 { font-size: 0.9rem; font-weight: 600; color: #444; margin: 0 0 0.28rem; }
  .renewable-legend { color: #c0392b; }

  #error,
  #empty {
    display: none;
    border-radius: 8px;
    padding: 0.78rem;
    margin-bottom: 1rem;
  }
  #error {
    background: #fff3f3;
    border: 1px solid #f5c0c0;
    color: #c00;
  }
  #empty {
    background: #fff9e9;
    border: 1px solid #f0d58a;
    color: #7a5800;
  }
  #loading {
    display: none;
    position: fixed;
    bottom: 1.1rem;
    right: 1.1rem;
    z-index: 50;
    border-radius: 8px;
    padding: 0.52rem 0.9rem;
    font-size: 0.82rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    background: #eef6fb;
    border: 1px solid #b8d7e8;
    color: #2f5f78;
  }
