:root{
  --instrTop: 10px;
  --bg:#0b1220;
  --panel:#101c36;
  --panel2:#0f1a33;
  --border:#243258;
  --text:#e8eefc;
  --muted:#b7c2e3;
  --link:#9bb7ff;
  --danger:#ff6b6b;
}

*{box-sizing:border-box}

body{
  font-family:system-ui,Segoe UI,Roboto,Arial,sans-serif;
  margin:0;
  background:var(--bg);
  color:var(--text);
}

header{
  padding:16px 20px;
  background:var(--panel2);
  border-bottom:1px solid var(--border);
}

main{
  padding:20px;
  max-width:1100px;
  margin:0 auto;
}

h1,h2,h3{margin:0 0 10px 0}

a{color:var(--link)}

.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:14px;
}

.row{display:grid;grid-template-columns:1fr 1fr;gap:16px}

@media (max-width: 900px){
  .row{grid-template-columns:1fr}
}

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

input,button,select,textarea{
  width:100%;
  padding:10px;
  border-radius:10px;
  border:1px solid #2a3a66;
  background:var(--bg);
  color:var(--text);
}

button{cursor:pointer}

button.primary{
  background:#18326b;
  border-color:#2b4db1;
}

button.danger{
  background:#2a1010;
  border-color:#a33;
}

button.ghost{
  background:transparent;
}

.pill{
  display:inline-block;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid #2a3a66;
  background:var(--bg);
  font-size:12px;
  opacity:.95;
}

.hr{height:1px;background:var(--border);margin:14px 0}

.grid2{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}

@media (max-width: 900px){
  .grid2,.grid3{grid-template-columns:1fr}
}

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

.table th,.table td{
  border-bottom:1px solid var(--border);
  padding:8px 6px;
  text-align:left;
  vertical-align:top;
}

.table th{opacity:.9;font-weight:600}

.badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--bg);
  font-size:12px;
}

.badge.ok{border-color:#2a6;background:#0f2a18}
.badge.warn{border-color:#d2a522;background:#2a2410}
.badge.off{border-color:#a33;background:#2a1010}

.owner-header{display:flex;align-items:center;justify-content:flex-start;gap:12px;flex-wrap:wrap}
.owner-nav{position:relative;display:flex;gap:10px;align-items:center;justify-content:flex-start}
.owner-menu-button{
  width:auto;
  min-width:104px;
  background:#18326b;
  border-color:#2b4db1;
  font-weight:650;
}
.owner-menu-panel{
  position:absolute;
  top:calc(100% + 8px);
  left:0;
  right:auto;
  z-index:1000;
  min-width:240px;
  padding:8px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#0b1429;
  box-shadow:0 16px 36px rgba(0,0,0,.35);
}
.owner-menu-panel[hidden]{display:none!important}
.owner-menu-label{
  padding:8px 12px 4px;
  color:var(--muted);
  font-size:11px;
  font-weight:800;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.owner-menu-item{
  display:block;
  width:100%;
  padding:10px 12px;
  border-radius:10px;
  color:var(--text);
  text-decoration:none;
  background:transparent;
  border:0;
  text-align:left;
  font-size:14px;
}
.owner-menu-item:hover,.owner-menu-item:focus{background:#162448;outline:none}
.owner-menu-separator{height:1px;background:var(--border);margin:6px 4px}

/* App layout */

.shell{
  display:flex;
  min-height:calc(100vh - 64px);
}

.sidebar{
  width:260px;
  border-right:1px solid var(--border);
  background:var(--panel2);
  padding:14px;
}

/* Dashboard needs a wider left panel for the configurator */
.sidebar.dashboard{
  width:360px;
}

@media (max-width: 900px){
  .sidebar{width:210px}
}

.sidebar .navbtn{
  display:block;
  width:100%;
  padding:14px 12px;
  border-radius:12px;
  border:1px solid #2a3a66;
  background:var(--bg);
  color:var(--text);
  font-size:16px;
  font-weight:650;
  margin-bottom:10px;
}

.sidebar .navbtn.active{
  border-color:#9bb7ff;
}

.content{
  flex:1;
  padding:20px;
}

/* Guidance arrow */

.guide{
  position:relative;
  padding:16px;
  border:1px dashed #ff5a5a;
  border-radius:12px;
  background:rgba(255,90,90,0.06);
}

.guide .arrow{
  width:0;height:0;
  border-top:12px solid transparent;
  border-bottom:12px solid transparent;
  border-right:20px solid #ff5a5a;
  display:inline-block;
  margin-right:10px;
  vertical-align:middle;
}

.modalBack{
  position:fixed;
  left:0;top:0;right:0;bottom:0;
  background:rgba(0,0,0,0.65);
  display:none;
  align-items:center;
  justify-content:center;
  padding:20px;
}

.modal{
  max-width:640px;
  width:100%;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:14px;
}

/* Dashboard canvas + widgets */

.dashToolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--panel2);
  margin-bottom:12px;
}

.dashboardTabs{
  display:flex;
  align-items:flex-end;
  gap:4px;
  padding:8px 10px 0 10px;
  border:1px solid var(--border);
  border-bottom:none;
  border-radius:12px 12px 0 0;
  background:var(--panel2);
  overflow-x:auto;
}
.dashboardTab,.dashboardTabAdd{
  width:auto;
  min-width:0;
  border:1px solid rgba(255,255,255,0.14);
  border-bottom:none;
  border-radius:10px 10px 0 0;
  background:rgba(12,24,48,0.94);
  color:var(--text);
  padding:8px 11px;
  display:inline-flex;
  align-items:center;
  gap:8px;
  line-height:1;
  box-shadow:none;
  flex:0 0 auto;
}
.dashboardTab{max-width:220px}
.dashboardTab:hover,.dashboardTabAdd:hover{border-color:rgba(96,165,250,0.50)}
.dashboardTab.active{
  background:linear-gradient(180deg, rgba(37,99,235,0.42), rgba(29,78,216,0.30));
  border-color:rgba(96,165,250,0.70);
}
.dashboardTabName{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dashboardTabAdd{font-weight:900;font-size:16px;padding:7px 11px 8px 11px}
.dashboardTabs + .dashToolbar{
  border-top-left-radius:0;
  border-top-right-radius:0;
}

.dashArea{
  position:relative;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(255,255,255,0.02);
  min-height:720px;
  height:calc(100vh - 64px - 20px - 58px);
  overflow:auto;
}

.widget{
  position:absolute;
  box-sizing:border-box;
  --widget-ui-scale:1;
  display:flex;
  flex-direction:column;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
  box-shadow:0 10px 26px rgba(0,0,0,0.22);
}

.widgetHeader{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:calc(10px * var(--widget-ui-scale, 1)) calc(10px * var(--widget-ui-scale, 1));
  background:var(--panel2);
  border-bottom:1px solid var(--border);
  cursor:grab;
  user-select:none;
  touch-action: none;
}

.widgetHeader:active{cursor:grabbing}

.widgetTitle{
  font-weight:650;
  font-size:calc(14px * var(--widget-ui-scale, 1));
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.widgetActions{
  display:flex;
  align-items:center;
  gap:6px;
}

.widgetActions button{
  width:auto;
  padding:calc(6px * var(--widget-ui-scale, 1)) calc(8px * var(--widget-ui-scale, 1));
  border-radius:calc(10px * var(--widget-ui-scale, 1));
  font-size:calc(12px * var(--widget-ui-scale, 1));
}

.widgetBody{
  flex:1 1 auto;
  min-height:0;
  box-sizing:border-box;
  padding:calc(10px * var(--widget-ui-scale, 1));
  height:auto;
  overflow:hidden;
  font-size:calc(14px * var(--widget-ui-scale, 1));
}

.widgetBody,
.widgetBody *{
  scrollbar-width:none;
}

.widgetBody::-webkit-scrollbar,
.widgetBody *::-webkit-scrollbar{
  display:none;
}

.widgetBody .small{
  font-size:calc(12px * var(--widget-ui-scale, 1));
}

.widgetBody button,
.widgetBody input,
.widgetBody select,
.widgetBody textarea{
  font-size:calc(14px * var(--widget-ui-scale, 1));
}

.widgetBody button{
  padding:calc(8px * var(--widget-ui-scale, 1)) calc(10px * var(--widget-ui-scale, 1));
  min-height:calc(34px * var(--widget-ui-scale, 1));
}

.widgetBody input,
.widgetBody select,
.widgetBody textarea{
  padding:calc(8px * var(--widget-ui-scale, 1)) calc(10px * var(--widget-ui-scale, 1));
}

.widgetBody .table,
.widgetBody table{
  font-size:inherit;
}

.widgetBody .table th,
.widgetBody .table td,
.widgetBody table th,
.widgetBody table td{
  padding:calc(8px * var(--widget-ui-scale, 1)) calc(6px * var(--widget-ui-scale, 1));
}

.widgetBody .badge,
.widgetBody .pill{
  font-size:calc(12px * var(--widget-ui-scale, 1));
  padding:calc(2px * var(--widget-ui-scale, 1)) calc(8px * var(--widget-ui-scale, 1));
}

.widgetBody .hr{
  margin:calc(14px * var(--widget-ui-scale, 1)) 0;
}

.widgetBody .grid2,
.widgetBody .grid3{
  gap:calc(8px * var(--widget-ui-scale, 1));
}

.widgetBody .chartLegend{
  gap:calc(10px * var(--widget-ui-scale, 1)) calc(14px * var(--widget-ui-scale, 1));
}

.widgetBody .chartLegend .legendItem{
  gap:calc(8px * var(--widget-ui-scale, 1));
  font-size:calc(12px * var(--widget-ui-scale, 1));
}

.widgetBody .chartLegend .legendSwatch{
  width:calc(12px * var(--widget-ui-scale, 1));
  height:calc(12px * var(--widget-ui-scale, 1));
}

.widgetResize{
  position:absolute;
  right:0;
  bottom:0;
  width:22px;
  height:22px;
  border:none;
  background:transparent;
  cursor:nwse-resize;
  touch-action: none;
}


/* Dashboard canvas layer */
.dashCanvas{
  position: relative;
  box-sizing:border-box;
  background: rgba(255,255,255,0.015);
  min-width: 800px;
  min-height: 600px;
}
#paintCanvas{
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: none;
}
.dashItems{
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Stickers: images & text */
.dashSticker{
  position: absolute;
  border: 1px dashed rgba(255,255,255,0.14);
  border-radius: 10px;
  background: rgba(0,0,0,0.10);
  overflow: hidden;
  touch-action: none;
}
.dashSticker.selectedItem{
  outline: 2px solid rgba(64,156,255,0.65);
  outline-offset: 0px;
  z-index:1000;
}
.dashImage img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.dashCaption{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  text-align: center;
}
.dashText{
  padding: 10px;
}
.dashTextInner{
  white-space: pre-wrap;
  color: rgba(255,255,255,0.92);
  font-weight: 650;
  text-shadow: 0 1px 0 rgba(0,0,0,0.35);
}

/* Selected widget */
.widget.selectedItem{
  outline: 2px solid rgba(64,156,255,0.65);
  outline-offset: 0px;
  z-index:1000;
}

/* Configurator row details */
.itemDetails{
  margin-top: 8px;
}
.seriesBox{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.seriesRow{
  display: flex;
  gap: 8px;
  align-items: center;
}
.selectedRow{
  border-color: rgba(64,156,255,0.55);
  box-shadow: 0 0 0 1px rgba(64,156,255,0.35);
}

/* Tool buttons */
.toolbtn.activeTool{
  border-color: rgba(64,156,255,0.55) !important;
  box-shadow: 0 0 0 1px rgba(64,156,255,0.35);
}

.slotRow{
  border:1px solid rgba(255,255,255,0.06);
  border-radius:12px;
  padding:10px;
  margin-top:10px;
  background:rgba(0,0,0,0.12);
}

.slotRow .slotTop{
  display:flex;
  gap:8px;
}

.slotRow .slotTop button{
  width:auto;
  padding:10px;
}

.slotRow label{
  display:block;
  font-size:12px;
  opacity:.9;
  color:var(--muted);
  margin:6px 0 4px 0;
}

.chartLegend{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:8px;
}

.legendItem{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  color:var(--muted);
}

.legendSwatch{
  width:10px;
  height:10px;
  border-radius:3px;
  border:1px solid rgba(255,255,255,0.18);
}

/* Autocomplete */

.autoWrap{position:relative}

.suggestBox{
  position:absolute;
  left:0;
  right:0;
  top:calc(100% + 6px);
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  max-height:240px;
  overflow:auto;
  z-index:50;
  display:none;
}

.suggestItem{
  padding:10px;
  border-bottom:1px solid rgba(255,255,255,0.06);
  cursor:pointer;
}

.suggestItem:last-child{border-bottom:none}

.suggestItem:hover{background:rgba(255,255,255,0.04)}

.suggestTitle{font-weight:650}

.suggestSub{opacity:.85;font-size:12px;color:var(--muted);margin-top:2px}

/* ------------------------------------------------------------------
   Dashboard builder (Översikt): widgetbibliotek + högerinspektor
   ------------------------------------------------------------------ */

.dashboardBuilder .inspector.dashboardInspector{
  width:420px;
  flex:0 0 420px;
  border-left:1px solid var(--border);
  background:rgba(0,0,0,0.08);
  padding:12px;
  overflow:auto;
}

@media (max-width: 1100px){
  /* På mindre skärmar krymper vi inspektören istället för att gömma den.
     Annars går det inte att se parametrar eller ta bort widgets. */
  .dashboardBuilder .inspector.dashboardInspector{width:320px;flex:0 0 320px}
  .sidebar.dashboard{width:300px}
}


.dashboardBuilder .paletteList{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:8px;
}

.dashboardBuilder .paletteItem{
  padding:10px;
  border:1px solid rgba(255,255,255,0.08);
  border-radius:10px;
  background:rgba(255,255,255,0.03);
  cursor:grab;
  user-select:none;
}

.dashboardBuilder .paletteItem:hover{background:rgba(255,255,255,0.05)}

.dashboardBuilder .paletteItem:active{cursor:grabbing}

.dashboardBuilder .objectList{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:8px;
  max-height:220px;
  overflow:auto;
}

.dashboardBuilder .objectRow{
  padding:8px 10px;
  border:1px solid rgba(255,255,255,0.06);
  border-radius:10px;
  background:rgba(255,255,255,0.02);
  cursor:pointer;
}

.dashboardBuilder .objectRow:hover{background:rgba(255,255,255,0.05)}

.dashboardBuilder .objectRow.selected{
  border-color:rgba(109,210,255,0.55);
  background:rgba(109,210,255,0.10);
}

.dashboardBuilder .miniGrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-top:8px;
}

.dashboardBuilder .miniGrid input{width:100%}

.dashboardBuilder .seriesBox{
  margin-top:8px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.dashboardBuilder .seriesRow{
  display:flex;
  gap:8px;
  align-items:center;
}

.dashboardBuilder .seriesRow select{min-width:120px}

.dashboardBuilder .seriesSearchResults{
  margin-top:8px;
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:220px;
  overflow:auto;
}
/* -------------------------------------------------------------------------- */
/* Instrumentmeny (instrument-UI)                                             */
/* -------------------------------------------------------------------------- */

.instrMenuBtn{
  position:fixed;
  top:var(--instrTop, 10px);
  left:10px;
  z-index:10000;
  width:44px;
  height:44px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  background:rgba(0,0,0,0.35);
  border:1px solid rgba(255,255,255,0.14);
  color:rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  font-size:24px;
  font-weight:800;
  line-height:1;
}
.instrMenuBtn:hover{ background:rgba(255,255,255,0.06); }

/* Snabbknapp: Översikt (utanför menyn). */
body.instrumentHeader:not(.dashboardView){
  padding-top:72px;
}

body.instrumentHeader:not(.dashboardView)::before{
  content:"";
  position:fixed;
  left:0;
  right:0;
  top:0;
  height:72px;
  z-index:9999;
  background:rgba(9,20,42,0.98);
  border-bottom:1px solid rgba(148,163,184,0.22);
  box-shadow:0 10px 22px rgba(0,0,0,0.30);
}

body.instrumentHeader:not(.dashboardView) .instrMenuBtn,
body.instrumentHeader:not(.dashboardView) .instrHomeBtn,
body.instrumentHeader:not(.dashboardView) .overviewQuickBtn{
  background:#0b1220;
  border-color:#2a3a66;
  box-shadow:0 8px 18px rgba(0,0,0,0.24);
}

body.instrumentHeader:not(.dashboardView) .instrMenuBtn:hover,
body.instrumentHeader:not(.dashboardView) .instrHomeBtn:hover,
body.instrumentHeader:not(.dashboardView) .overviewQuickBtn:hover{
  background:#111d39;
}

.instrHomeBtn{
  position:fixed;
  top:var(--instrTop, 10px);
  left:62px;
  z-index:10000;
  width:auto;
  white-space:nowrap;
  max-width:calc(100vw - 74px);
  height:44px;
  padding:0 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  background:rgba(0,0,0,0.35);
  border:1px solid rgba(255,255,255,0.14);
  color:rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  font-size:14px;
  font-weight:700;
  letter-spacing:0.2px;
}
.instrHomeBtn:hover{ background:rgba(255,255,255,0.06); }

.dashboardOverviewQuickTabs{
  position:fixed;
  top:var(--instrTop, 10px);
  left:62px;
  z-index:10000;
  display:flex;
  align-items:center;
  gap:6px;
  max-width:calc(100vw - 74px);
  overflow-x:auto;
  padding-bottom:2px;
}
.dashboardOverviewQuickTabs .instrHomeBtn{
  position:static;
  top:auto;
  left:auto;
  flex:0 0 auto;
  max-width:180px;
}
.dashboardOverviewQuickTabs .instrHomeBtn.active{
  border-color:rgba(96,165,250,0.65);
  background:rgba(37,99,235,0.38);
}
.overviewQuickBtn{
  width:auto;
  white-space:nowrap;
  height:44px;
  padding:0 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  background:rgba(0,0,0,0.35);
  border:1px solid rgba(255,255,255,0.14);
  color:rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  font-size:14px;
  font-weight:700;
  letter-spacing:0.2px;
}
.overviewQuickBtn:hover{ background:rgba(255,255,255,0.06); }
.overviewQuickBtn.active{
  border-color:rgba(96,165,250,0.65);
  background:rgba(37,99,235,0.38);
}

.instrMenuOverlay{
  position:fixed;
  inset:0;
  z-index:10001;
  background:rgba(0,0,0,0.45);
  display:none;
}

.instrMenuPanel{
  position:absolute;
  top:0;
  left:0;
  height:100%;
  width:320px;
  max-width:calc(100vw - 24px);
  background:var(--panel);
  border-right:1px solid var(--border);
  padding:14px;
  box-sizing:border-box;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.instrMenuTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.instrMenuTitle{
  font-weight:800;
  letter-spacing:0.2px;
}

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

.instrMenuItem{
  width:100%;
  text-align:left;
  padding:12px;
  border:1px solid rgba(255,255,255,0.10);
  border-radius:12px;
  background:rgba(255,255,255,0.03);
  color:rgba(255,255,255,0.92);
  cursor:pointer;
}

.instrMenuItem:hover{ background:rgba(255,255,255,0.06); }

.instrMenuItem.active{
  border-color:rgba(109,210,255,0.55);
  background:rgba(109,210,255,0.10);
}

.instrMenuSpacer{ flex:1; }

.instrMenuDanger{
  border-color:rgba(239,68,68,0.45);
  background:rgba(239,68,68,0.10);
}

/* -------------------------------------------------------------------------- */
/* Översikt – ren visning (fullskärm)                                         */
/* -------------------------------------------------------------------------- */

.dashboardView::before{
  content:"";
  position:fixed;
  left:0;
  right:0;
  top:0;
  height:72px;
  z-index:9999;
  background:rgba(9,20,42,0.98);
  border-bottom:1px solid rgba(148,163,184,0.22);
  box-shadow:0 10px 22px rgba(0,0,0,0.30);
}

.dashAreaFullscreen{
  position:fixed;
  inset:0;
  border:none;
  border-radius:0;
  background:transparent;
  min-height:0;
  height:100vh;
  overflow:auto;
}

.dashboardView .dashAreaFullscreen{
  top:72px;
  height:auto;
  overflow:hidden;
  display:flex;
  align-items:flex-start;
  justify-content:flex-start;
}

.dashboardView .dashCanvas{
  background:transparent;
  min-width:0;
  min-height:0;
  flex:0 0 auto;
}

.dashboardView .dashSticker{
  border:none;
  background:transparent;
}

.dashboardView .widgetHeader{
  cursor:default;
  padding:7px 9px;
}

.dashboardView .widgetHeader:active{
  cursor:default;
}

.dashboardView .widgetResize{
  display:none;
}

.dashboardView .widgetBody{
  padding:calc(8px * var(--widget-ui-scale, 1));
  height:auto;
  overflow:hidden;
}

.dashboardView .widgetTitle{
  font-size:calc(13px * var(--widget-ui-scale, 1));
}

.dashboardView .small{
  line-height:1.25;
}

.dashboardView .selectedItem{
  outline:none !important;
}

.dashboardView header{display:none !important;}
.dashboardView .sidebar{display:none !important;}
.dashboardView .inspector{display:none !important;}
.dashboardView .dashToolbar{display:none !important;}
.dashboardView .shell{max-width:none;margin:0;padding:0}
.dashboardView .content{padding:0}


/* ------------------------------------------------------------
   Diagram (stapel + linje): legend under graf + tooltip
   ------------------------------------------------------------ */

.chartLegend{
  display:flex;
  flex-wrap:wrap;
  gap:10px 14px;
  justify-content:center;
  align-items:center;
  padding:2px 4px 0 4px;
}

.chartLegend .legendItem{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  line-height:1.2;
  color: rgba(255,255,255,0.85);
  white-space:nowrap;
}

.chartLegend .legendSwatch{
  width:12px;
  height:12px;
  border-radius:3px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.20);
  flex:0 0 auto;
}

.chartTooltip{
  position:absolute;
  z-index:5;
  pointer-events:none;
  background: rgba(255,255,255,0.96);
  color:#111;
  padding:10px 12px;
  border-radius:10px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
  font-size:13px;
  line-height:1.35;
  min-width: 180px;
  max-width: 300px;
}

.chartTooltip .ttTs{
  font-weight:650;
  margin-bottom:6px;
}

.chartTooltip .ttRow{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:10px;
}

.chartTooltip .ttName{
  flex:1 1 auto;
  font-weight:600;
}

.chartTooltip .ttVal{
  flex:0 0 auto;
  font-variant-numeric: tabular-nums;
  color:#111;
}


/* --------------------------------------------------------------------------
   Dashboard: Site overview widgets (heat balance / dispatch carpet / explain)
   -------------------------------------------------------------------------- */

.dispatchCarpet{
  display:block;
  width:100%;
  height:100%;
  border-radius: 10px;
}

.hr{
  height:1px;
  background: rgba(255,255,255,0.12);
}

.planExplain{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.explainBox{
  flex:1 1 auto;
  overflow:auto;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.10);
}

.explainRow{
  margin-bottom: 8px;
}

.explainGrid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.explainSection{
  margin-top: 10px;
}

.explainSection ul{
  margin: 6px 0 0 18px;
}

.explainList{
  display:flex;
  flex-direction:column;
  gap: 2px;
  margin-top: 6px;
}

.explainListRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.warnBox{
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255,170,0,0.12);
  border: 1px solid rgba(255,170,0,0.22);
}

.muted{
  opacity: 0.78;
}
