  :root{--border:#d7deea; --text:#111827; --muted:#667085; --bg:#f3f6fb; --tab-underline:#1d4ed8; --panel:#fff; --panel2:#f8fbff; --shadow: rgba(15,23,42,0.10); --chart-bg: rgba(29,78,216,0.04); --day-boundary-color: rgba(15,23,42,0.08); --extrema-min: rgba(30,136,229,0.95); --extrema-max: rgba(229,57,53,0.95); --extrema-ring: rgba(255,255,255,0.85); --accent:#2563eb; --accent-strong:#1d4ed8; --accent-soft:#dbeafe; --panel-raised:#ffffff; --panel-glow:0 14px 34px rgba(37,99,235,0.14); --button-shadow:0 8px 18px rgba(15,23,42,0.10); --button-shadow-hover:0 12px 24px rgba(37,99,235,0.18); --button-shadow-press:0 4px 10px rgba(15,23,42,0.12); --focus-ring:0 0 0 3px rgba(37,99,235,0.20);}
  /* Theme */
  html[data-theme="dark"]{
    --chart-bg: rgba(255,255,255,0.04); --day-boundary-color: rgba(255,255,255,0.06); --extrema-min: rgba(64,156,255,0.95); --extrema-max: rgba(255,96,96,0.95); --extrema-ring: rgba(0,0,0,0.55);
    --border:#273245;
    --text:#eef4ff;
    --muted:#9eacc4;
    --bg:#0b1220;
    --tab-underline:#8fb7ff;
    --panel:#101827;
    --panel2:#0f1724;
    --shadow: rgba(0,0,0,0.45);
    --accent:#60a5fa;
    --accent-strong:#8fb7ff;
    --accent-soft:rgba(96,165,250,0.12);
    --panel-raised:#111b2d;
    --panel-glow:0 14px 34px rgba(0,0,0,0.34);
    --button-shadow:0 8px 22px rgba(0,0,0,0.30);
    --button-shadow-hover:0 12px 30px rgba(96,165,250,0.16);
    --button-shadow-press:0 4px 10px rgba(0,0,0,0.26);
    --focus-ring:0 0 0 3px rgba(96,165,250,0.20);
  }
  html[data-theme="light"]{
    --panel:#ffffff;
    --panel2:#f8fbff;
    --shadow: rgba(15,23,42,0.10);
  }

  html, body { height:100%; margin:0; background:var(--bg); color:var(--text); font-family:var(--ui-font, "Arimo", Arial, Helvetica, sans-serif);font-variant-numeric: tabular-nums; }
  body { display:flex; flex-direction:column; }
  button, input, select, textarea, option { font: inherit; font-family: inherit; }

  .top { border-bottom:1px solid var(--border); padding:10px 12px 6px 12px; background:linear-gradient(180deg, rgba(255,255,255,0.50), rgba(255,255,255,0.16)); backdrop-filter:saturate(1.05); }
  html[data-theme="dark"] .top{ background:linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)); }
  .tabs { display:flex; gap:8px; align-items:flex-end; margin-bottom:10px; flex-wrap:wrap; }
  .tab { appearance:none; border:1px solid var(--border); border-bottom-color:transparent; background:linear-gradient(180deg, rgba(255,255,255,0.45), rgba(255,255,255,0.12)); font-size:13px; font-weight:700; padding:8px 13px 9px 13px; cursor:pointer; color:var(--muted); border-radius:5px 5px 0 0; transition:background .16s ease,color .16s ease,transform .12s ease,box-shadow .16s ease,border-color .16s ease; }
  .tab:hover { color:var(--text); background:var(--accent-soft); border-color:rgba(37,99,235,0.18); transform:translateY(-1px); }
  .tab.active { color:var(--accent-strong); background:linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.90)); border-color:rgba(37,99,235,0.22); border-bottom-color:var(--bg); box-shadow:none; font-weight:800; }
  html[data-theme="dark"] .tab.active{ background:linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)); }

  #exportCsv{ height:34px; font-size:12px; padding:0 13px; cursor:pointer; margin-bottom:0; font-weight:800; }
  .tabs #settingsBtn, .tabs #aboutBtn{
    height:34px;
    font-size:12px;
    padding:0 13px;
    cursor:pointer;
    margin-bottom:0;
    font-weight:800;
  }


  .bar{ display:flex; flex-wrap:wrap; gap:10px 12px; align-items:center; padding:0 0 10px 0; }
  .bar label{ font-size:13px; color:var(--muted); display:flex; gap:8px; align-items:center; font-weight:600; }
  .bar input:not(.ui-switch), .bar select, .bar button{ height:38px; font-size:13px; }
  .bar button{ padding:0 13px; cursor:pointer; font-weight:800; }
  .spacer{
    margin-left:auto;
    flex: 1;
  }
  
  /* Form theme */
  input, select, button, textarea{
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    box-shadow: 0 1px 0 rgba(255,255,255,0.45) inset;
    transition: border-color .16s ease, box-shadow .16s ease, transform .12s ease, background .16s ease;
  }
  html[data-theme="dark"] input,
  html[data-theme="dark"] select,
  html[data-theme="dark"] button,
  html[data-theme="dark"] textarea{
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  }
  button{ background: linear-gradient(180deg, var(--panel-raised), var(--panel2)); box-shadow: var(--button-shadow); font-weight:700; }
  button:hover{ transform:translateY(-1px); border-color:rgba(37,99,235,0.22); box-shadow:var(--button-shadow-hover); }
  button:active{ transform:translateY(1px) scale(0.99); box-shadow:var(--button-shadow-press); }
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible{
    outline:none;
    border-color:var(--accent);
    box-shadow:var(--focus-ring);
  }
  input:hover, select:hover, textarea:hover{
    border-color:rgba(37,99,235,0.22);
  }
  input::placeholder, textarea::placeholder{ color: var(--muted); }

#load, #btnToday, #btnTomorrow, #exportCsv, #settingsBtn, #aboutBtn{
    position:relative;
  }

  .bar > .spacer{
    display:none;
  }

  #btnToday, #btnTomorrow, #load{
    background: linear-gradient(180deg, rgba(37,99,235,0.12), rgba(37,99,235,0.06));
  }

  #exportCsv{
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    color:#fff;
    border-color:transparent;
  }

  .icon-action-btn{
    width:34px;
    height:34px;
    padding:0;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:17px;
    line-height:1;
    font-weight:900;
    color:#dc2626;
    background:linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.74));
  }
  .icon-action-btn:hover{
    background:linear-gradient(180deg, rgba(254,226,226,0.95), rgba(254,242,242,0.86));
  }
  html[data-theme="dark"] .icon-action-btn{
    background:linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
    color:#fda4af;
  }

  #settingsBtn, #aboutBtn{
    background: linear-gradient(180deg, rgba(255,255,255,0.90), rgba(255,255,255,0.68));
  }
  html[data-theme="dark"] #settingsBtn,
  html[data-theme="dark"] #aboutBtn{
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  }

  .quick-toggles{
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
    font-size:12px;
  }

.quick-toggle{
  display:inline-flex;
  align-items:center;
  justify-content:flex-start;
  gap:8px;
  min-height:28px;
  padding:0 9px;
    background:linear-gradient(180deg, rgba(255,255,255,0.76), rgba(255,255,255,0.52));
    border:1px solid var(--border);
    border-radius:5px;
    color:var(--text);
    box-shadow:0 3px 10px rgba(15,23,42,0.06);
    cursor:pointer;
    transition:transform .12s ease,border-color .16s ease,box-shadow .16s ease,background .16s ease;
  }

  html[data-theme="dark"] .quick-toggle{
    background:linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03));
  }

  .quick-toggle:hover{
    transform:translateY(-1px);
    border-color:rgba(37,99,235,0.25);
    box-shadow:0 7px 14px rgba(37,99,235,0.10);
  }

  .ui-switch{
    appearance:none;
    -webkit-appearance:none;
    width:28px;
    height:15px;
    min-width:28px;
    border-radius:999px;
    border:1px solid rgba(15,23,42,0.14);
    background:linear-gradient(180deg, rgba(148,163,184,0.34), rgba(148,163,184,0.18));
    box-shadow:none;
    position:relative;
    cursor:pointer;
    transition:background .16s ease,border-color .16s ease,transform .12s ease;
    flex:0 0 auto;
  }

  .ui-switch::after{
    content:"";
    position:absolute;
    top:1px;
    left:1px;
    width:11px;
    height:11px;
    border-radius:999px;
    background:#fff;
    box-shadow:0 1px 4px rgba(15,23,42,0.20);
    transition:transform .16s ease;
  }

  .ui-switch:hover{
    border-color:rgba(37,99,235,0.26);
  }

  .ui-switch:checked{
    background:linear-gradient(180deg, var(--accent), var(--accent-strong));
    border-color:transparent;
  }

  .ui-switch:checked::after{
    transform:translateX(12px);
  }

  .quick-toggle .ui-switch{
    margin-left:0;
    margin-right:2px;
  }

  .legend-item .ui-switch,
  .ep-check-chip .ui-switch,
  .ep-switch-row .ui-switch,
  .ep-area-grid .ui-switch{
    width:28px;
    min-width:28px;
    max-width:28px;
    height:15px;
    flex:0 0 28px;
  }







  .main{ flex:1; min-height:0; }
  .view{ height:100%; display:none; padding-bottom: 120px; box-sizing:border-box; }
  .view.active{ display:block; }
  .chart-wrap{ height: min(var(--graphH, 500px), 100%); box-sizing:border-box; position:relative; }
  canvas{ width:100% !important; height:100% !important; }

  .table-wrap{ height:100%; overflow:auto; }
  #legendBar{display:none; padding-left:16px; }
  .legend-item{ display:inline-flex; gap:6px; align-items:center; user-select:none; ; flex:0 0 auto}
  .legend-item{ flex:0 0 auto; }

  .legend-swatch{ width:10px; height:10px; border-radius:50%; border:1px solid rgba(0,0,0,0.25); }
.legend-item input{ margin:0; }
.legend-item .ui-switch{ margin-right:2px; }
.legend-item span{ color:var(--text); }

  table{ border-collapse:collapse; width:100%; font-size:12px; }
  thead th{ position:sticky; top:0; background:#fafafa; border-bottom:1px solid var(--border); text-align:left; padding:8px 10px; color:#333; z-index:1; }
  tbody td{ border-bottom:1px solid #eee; padding:7px 10px; white-space:nowrap; }
  .pill{ display:inline-block; padding:2px 8px; border-radius:999px; font-weight:800; font-variant-numeric: tabular-nums; }

  /* Floating popup (hidden unless hovering chart) */
  .float-price{
    display:none;
    position:absolute;
    z-index:60;
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 2.5px;
    padding: 10px 12px;
    box-shadow:0 6px 18px rgba(255,255,255,0.80);
    backdrop-filter: blur(6px);
    font-size: 12px;
    min-width: 240px;
    pointer-events:none;
  }
  .float-price .row{ display:flex; justify-content:space-between; gap:10px; }
  .float-price .label{ color:var(--muted); }
  .float-price .val{ font-weight:700; font-variant-numeric: tabular-nums; }
  .float-price .big{ font-size:14px; line-height:1.25; margin-top:6px; font-weight:700; }
  .float-price .swatch{ display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:6px; vertical-align:middle; border:1px solid rgba(0,0,0,0.2); background:transparent; }

  /* Settings modal layout */
  .modal.settings{
    max-width: 420px;
    width: 92vw;
    max-height: 90vh;
    display:flex;
    flex-direction:column;
  }
  .modal.settings .content{
    overflow-y:auto;
    padding-right:6px;
  }
  .settings-grid{
    display:flex;
    flex-direction:column;
    gap:18px;
  }


  /* Narrow numeric inputs in Settings */
  .modal.settings input[type='number']{ width:20px; }
  .modal.settings select{ height:24px; }

  /* Graph sizing modes */
  /* Allow content to grow (e.g., multi-row legend) without overlapping the chart */
  #viewGraph{ display:flex; flex-direction:column; min-height:0; overflow-y:auto; }
  html.graph-viewport .chart-wrap{ height:100%; flex:1; }


  #date{
    min-width:104px;
    font-size:13px;
    font-weight:600;
    letter-spacing:0.01em;
  }

  #area{
    min-width:96px;
    font-size:13px;
    font-weight:600;
  }

  .price-header{
    background: var(--bg);
    padding: 10px 16px 12px 16px;
    display:flex;
    justify-content:flex-start; /* keep header content on the left */
    align-items:flex-start;
    text-align:left;
  }

.price-header-grid{
      display:grid;
      grid-template-columns:minmax(160px, 220px) minmax(320px, 1fr);
      gap:12px;
      width:100%;
      align-items:stretch;
    }

  .price-header-grid.top-spread-hidden{
    grid-template-columns:minmax(160px, 220px);
    width:auto;
  }

  .price-header-grid.top-spread-hidden .fixed-price-box{
    min-height:auto;
    align-self:start;
    padding:6px 10px;
    gap:2px;
  }
  
.fixed-price-box{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  text-align:center;
  pointer-events:none; /* behåll bara om du verkligen vill */
  min-height:94px;
  padding:8px 12px;
  border:1px solid var(--border);
  border-radius:6px;
  background:linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.78));
  box-shadow:var(--panel-glow);
  align-self:stretch;
}

.quick-toggle span{
  flex:1 1 auto;
}
html[data-theme="dark"] .fixed-price-box{ background:linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.03)); }

.fixed-price-box .meta,
.fixed-price-box .range{
  font-size:11px;
  color:var(--muted);
}

#fpRange{
  font-size:12.5px;
  font-weight:700;
  color:var(--text);
  opacity:0.92;
}

.fixed-price-box .value{
  display:flex;
  align-items:baseline;
  justify-content:center;
  font-size:21px;
  font-weight:800;
  line-height:1.05;
  color:var(--text);
  font-variant-numeric: tabular-nums;
}

.fixed-price-box .unit{
  font-size:12px;
  font-weight:500;
  opacity:.85;
  margin-left:4px;
}


#fpRange:empty{ display:none; }

/* Om fpMeta är en specialvariant, annars ta bort och använd .meta */
#fpMeta{
  font-size:11px;
  color:var(--muted);
  margin-top:0;
}

.price-header .statsSpreadCard{
  margin:0;
  height:100%;
  box-sizing:border-box;
}

.statsSpreadCard-top .statsSpreadGrid{
  grid-template-columns:minmax(0, 1fr) minmax(220px, 1fr);
}

.statsSpreadCard-top .statsSpreadNote{
  font-size:10px;
}

@media (max-width:520px){
  .price-header-grid{
    align-items:start;
  }
  .fixed-price-box{
    min-height:auto;
    align-items:flex-start;
    justify-content:flex-start;
    text-align:left;
    gap:2px;
    padding:6px 10px;
    align-self:start;
  }
  .fixed-price-box .value{
    justify-content:flex-start;
  }
  .fixed-price-box .value{ font-size:19px; }
  .fixed-price-box .unit{ font-size:11px; }
  .fixed-price-box .meta,
  .fixed-price-box .range{ font-size:9.5px; }
  #fpRange{ font-size:11px; }
}



  
/* Stats bar (fixed bottom) */
#statsWrap{
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: 1;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 14px 12px 16px 12px;
  color: var(--text);
  font-size: 12px;
}
.statsInner{
  max-width: 1100px;
  margin: 0 auto;
}
.statsGrid{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.statCell{
  position:relative;
  overflow:hidden;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,251,255,0.86));
  border-radius: 7px;
  padding: 8px 11px 7px 11px;
  text-align: left;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--panel-glow), 0 3px 10px rgba(15,23,42,0.08);
}
html[data-theme="dark"] .statCell{
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.025));
}
.statCell::before{
  content:"";
  position:absolute;
  inset:0 auto 0 0;
  width:5px;
  border-radius:7px 0 0 7px;
  background:linear-gradient(180deg, rgba(37,99,235,0.95), rgba(96,165,250,0.75));
}
.statLabel{
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.statValue{
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-top: 0;
}
.statUnit{
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
  white-space: nowrap;
}
.statSub{
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 11px;
}
.statsExtra{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.statsExtra-cheapest{
      display:flex;
      align-items:flex-start;
    }

.statsExtra-costliest{
      display:flex;
      align-items:flex-start;
    }

#statCostliest,
#statCheapest{
      display:flex;
      flex-wrap:wrap;
      gap:8px;
      align-items:center;
    }

.statsHighlights{
        display:grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap:10px 18px;
        align-items:start;
      }

.cheapest-label{
  display:inline-flex;
  align-items:center;
  min-height:34px;
  padding:0 12px;
  border-radius:5px;
  background:var(--accent-soft);
  color:var(--accent-strong);
  font-size:11px;
  font-weight:800;
  letter-spacing:0.03em;
  text-transform:uppercase;
  box-shadow:0 8px 20px rgba(37,99,235,0.18);
}

.expensive-label{
  background:rgba(249,115,22,0.12);
  color:#c2410c;
  box-shadow:0 8px 20px rgba(249,115,22,0.16);
}

.cheapest-chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:34px;
  padding:0 12px;
  border:1px solid var(--border);
  border-radius:5px;
  background:linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.72));
  box-shadow:0 8px 20px rgba(15,23,42,0.10);
}

html[data-theme="dark"] .cheapest-chip{
  background:linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
}

.expensive-value{
  color:#c2410c;
}

.statsSpreadCard{
  border:1px solid var(--border);
  border-radius:5px;
  padding:8px 12px;
  background:linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,251,255,0.88));
  box-shadow:0 10px 22px rgba(15,23,42,0.10);
  display:grid;
  gap:6px;
}

html[data-theme="dark"] .statsSpreadCard{
  background:linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
}

.statsSpreadGrid{
  display:grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 1fr);
  gap:10px;
  align-items:start;
}

.statsSpreadMain,
.statsSpreadSide{
  display:grid;
  gap:4px;
}

.statsSpreadCard-top .statsSpreadSide{
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "label label"
    "value prices"
    "times times"
    "trade trade";
  column-gap:10px;
  row-gap:2px;
  align-items:end;
}

.statsSpreadCard-top .statsSpreadSide .statsSpreadLabel{ grid-area:label; }
.statsSpreadCard-top .statsSpreadSide .statsSpreadTradeValue{ grid-area:value; }
.statsSpreadCard-top .statsSpreadSide .statsSpreadTradePrices{ grid-area:prices; align-self:end; }
.statsSpreadCard-top .statsSpreadSide .statsSpreadTradeTimes{ grid-area:times; }
.statsSpreadCard-top .statsSpreadSide .statsSpreadTrade{ grid-area:trade; }

.statsSpreadLabel{
  font-size:11px;
  font-weight:800;
  letter-spacing:0.04em;
  text-transform:uppercase;
  color:var(--muted);
}

.statsSpreadValue{
  font-size:18px;
  font-weight:800;
  color:var(--text);
  line-height:1.1;
  font-variant-numeric:tabular-nums;
}

.statsSpreadTradeValue{
  font-size:24px;
  font-weight:900;
  color:var(--accent-strong);
  line-height:1.05;
  font-variant-numeric:tabular-nums;
}

.statsSpreadTradeValue.is-loss{
  color:#dc2626;
}

.statsSpreadTradePrices{
  font-size:15px;
  font-weight:800;
  color:var(--text);
  line-height:1.2;
  font-variant-numeric:tabular-nums;
}

.statsSpreadTradePrices .sep{
  opacity:0.45;
  margin:0 6px;
}

.statsSpreadTradeTimes{
  font-size:10px;
  color:var(--muted);
  line-height:1.3;
}

.statsSpreadSub{
  font-size:10px;
  color:var(--muted);
  line-height:1.35;
}

.statsSpreadTrade{
  font-size:10.5px;
  color:var(--text);
  line-height:1.4;
}

.statsSpreadNote{
  padding-top:5px;
  border-top:1px solid rgba(148,163,184,0.24);
  font-size:9.5px;
  color:var(--muted);
  line-height:1.35;
}

.table-actions{
  display:flex;
  justify-content:flex-start;
  padding:10px 16px 8px 16px;
  background:var(--bg);
}

.ep-field-row.is-disabled{
  opacity:0.52;
}

.ep-field-row.is-disabled select,
.ep-field-row.is-disabled input{
  cursor:not-allowed;
}

.cheapest-when{
  font-size:12px;
  font-weight:700;
  color:var(--text);
}

.cheapest-value{
  font-size:12px;
  font-weight:800;
  color:var(--accent-strong);
}

.statCell-now::before{ background:linear-gradient(180deg, #2563eb, #60a5fa); }
.statCell-avg::before{ background:linear-gradient(180deg, #7c3aed, #a78bfa); }
.statCell-low::before{ background:linear-gradient(180deg, #059669, #34d399); }
.statCell-high::before{ background:linear-gradient(180deg, #ea580c, #fb923c); }

thead th{
  background:linear-gradient(180deg, rgba(255,255,255,0.98), rgba(243,246,251,0.98));
  color:var(--text);
  border-bottom:1px solid var(--border);
}
html[data-theme="dark"] thead th{
  background:linear-gradient(180deg, rgba(17,24,39,0.98), rgba(15,23,36,0.98));
}
@media (max-width: 720px){
  .statsGrid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs{ gap:8px; }
  .tab{ padding:7px 11px 8px 11px; }
}
@media (max-width: 520px){
  .top{ padding:10px 10px 8px 10px; }
  .bar{
    display:grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-areas:
      "date date date date date date area area area area area area"
      "today today today today today today tomorrow tomorrow tomorrow tomorrow tomorrow tomorrow"
      "vat vat vat vat vat vat energy energy energy energy energy energy"
      "supplier supplier supplier supplier supplier supplier transfer transfer transfer transfer transfer transfer";
    gap:8px;
    align-items:start;
  }
  .bar > label:first-of-type{
    grid-area:date;
    width:auto;
  }
  #btnToday{
      grid-area:today;
      width:100%;
      min-width:0;
      height:34px;
      padding:0 8px;
      font-size:12px;
    }
  #btnTomorrow{
      grid-area:tomorrow;
      width:100%;
      min-width:0;
      height:34px;
      padding:0 8px;
      font-size:12px;
    }
  .bar > label:nth-of-type(2){
    grid-area:area;
    width:auto;
  }
  #quickToggles{
    grid-column: 1 / -1;
    width:auto;
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "vat energy"
      "supplier transfer";
    gap:8px;
    align-items:start;
  }
  #quickToggles .quick-toggle:nth-child(1){ grid-area:vat; }
  #quickToggles .quick-toggle:nth-child(2){ grid-area:energy; }
  #quickToggles .quick-toggle:nth-child(3){ grid-area:supplier; }
  #quickToggles .quick-toggle:nth-child(4){ grid-area:transfer; }
  .bar label{ width:auto; min-width:0; }
  .bar input:not(.ui-switch), .bar select, .bar button{ width:100%; }
  .bar label input:not(.ui-switch), .bar label select{ flex:1; min-width:0; }
  .quick-toggle{
    width:auto;
    min-width:0;
    max-width:100%;
  }
  .quick-toggle span{
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .price-header{ padding:8px 10px 12px 10px; }
  .price-header-grid{
    grid-template-columns:1fr;
    gap:8px;
  }
  .fixed-price-box{ width:100%; box-sizing:border-box; }
  #statsWrap{ padding: 12px 8px 14px 8px; }
  .statsHighlights{
      grid-template-columns: repeat(2, minmax(0, 1fr));
      align-items:start;
    }
    .statsGrid{ gap: 8px; }
  .statCell{ padding: 7px 9px 6px 9px; min-height:56px; }
  .statLabel{ margin-bottom:4px; }
  .statValue{ font-size: 15px; }
  .statUnit{ font-size:9.5px; }
  .statSub{ margin-top:2px; font-size:10px; min-height:10px; }
  .statsExtra{ margin-top:0; }
  #statCheapest{ gap:6px; }
  #statCostliest{ gap:6px; }
  .statsSpreadCard{ grid-column:1 / -1; }
  .cheapest-label, .cheapest-chip{ width:100%; justify-content:space-between; box-sizing:border-box; }
  #statCheapest, #statCostliest{ grid-template-columns: 1fr; }
  .statsSpreadCard{ padding:8px 9px; }
  .statsSpreadGrid{ grid-template-columns: 1fr; gap:10px; }
  .statsSpreadValue{ font-size:15px; }
  .statsSpreadTradeValue{ font-size:18px; }
  .statsSpreadTradePrices{ font-size:14px; }
  .statsSpreadTradeTimes{ font-size:10px; }
  .statsSpreadSub{ font-size:10px; }
  .statsSpreadTrade{ font-size:10px; }
  .statsSpreadNote{ font-size:9.5px; }
  .table-actions{ padding:8px 10px 6px 10px; }
}

/* =====================================================
   Legend Bar – Compact Layout
   ===================================================== */

#legendBar{
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;                /* mindre mellanrum */

  /* Compact by default (1 row) but naturally grows when wrapping to 2+ rows */
  padding: 2px 12px 4px 12px;
  margin: 0 0 6px 0;

  /* Prevent the chart from visually "bleeding" behind the legend when it wraps */
  background: var(--bg);
  overflow: visible;
}

#legendBar .legend-item{
  display: inline-flex;
  align-items: center;
  gap: 5px;

  font-size: 12px;
  line-height: 16px;       /* ↓ tightare rad */
  white-space: nowrap;
}

#legendBar .swatch{
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 2px;
}

/* Mobil */
@media (max-width: 720px){
  #legendBar{
    padding: 2px 12px;
    margin-bottom: 6px;
  }
}

#aboutModal h4 {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
}

#aboutModal .about-disclaimer {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--muted);
}

#aboutModal .about-disclaimer p {
    margin-bottom: 8px;
}

.about-copyright {
    font-size: 11.5px;
    color: var(--muted);
    text-align: center;
}
