/* Egen kod, idé från affectUI Analytics (Pro), ingen kod tagen */
/* Appram: sidomeny och huvudyta, delas av skärmarna men med eget prefix */
.nsan-root {
  --nsan-k: 0, 0, 0;
  --nsan-card: #ffffff;
  --nsan-soft: #FAFAF8;
  --nsan-strong: #000000;
  --nsan-ink: rgba(0, 0, 0, 0.88);
  --nsan-text: rgba(0, 0, 0, 0.61);
      --nsan-line: rgba(0, 0, 0, 0.06);
  --nsan-wash: rgba(0, 0, 0, 0.03);
  --nsan-side: #F2F1EE;
  --nsan-ember: #D9601C;
  --nsan-ember-ink: #A8460F;
  --nsan-ember-tint: rgba(217, 96, 28, 0.10);
  --nsan-ok: #1E7A4C;
  --nsan-ok-tint: rgba(30, 122, 76, 0.10);
  --nsan-wait: #8A5200;
  --nsan-wait-tint: rgba(178, 106, 0, 0.10);
  --nsan-bad: #B3261E;
  --nsan-solid: rgba(0, 0, 0, 0.88);
  --nsan-on-solid: #fcfcfc;
  --nsan-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 1px 1px -1px rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(var(--nsan-k), 0.05);
  --nsan-shadow-hover: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 1px 1px -1px rgba(0, 0, 0, 0.12), 0 1px 3px 0 rgba(var(--nsan-k), 0.07);
  --nsan-focus: rgba(217, 96, 28, 0.4);
  --nsan-ease: cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  box-sizing: border-box;
  container-type: inline-size;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 20px;
  color: var(--nsan-ink);
  text-align: left;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

/* Mörkt läge, samma konvention som affectUI */
:where(.dark, [data-theme="dark"]) .nsan-root {
  --nsan-k: 255, 255, 255;
  --nsan-card: #1C1B1A;
  --nsan-soft: #201F1E;
  --nsan-strong: rgba(255, 255, 255, 0.94);
  --nsan-ink: rgba(255, 255, 255, 0.9);
  --nsan-text: rgba(255, 255, 255, 0.64);
      --nsan-line: rgba(255, 255, 255, 0.08);
  --nsan-wash: rgba(255, 255, 255, 0.04);
  --nsan-side: #161615;
  --nsan-ember: #D9601C;
  --nsan-ember-ink: #F08A4B;
  --nsan-ember-tint: rgba(240, 138, 75, 0.14);
  --nsan-ok: #3EC27A;
  --nsan-ok-tint: rgba(62, 194, 122, 0.13);
  --nsan-wait: #F0B232;
  --nsan-wait-tint: rgba(240, 178, 50, 0.13);
  --nsan-bad: #F07A6E;
  --nsan-solid: rgba(255, 255, 255, 0.9);
  --nsan-on-solid: #161615;
  --nsan-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 1px 2px rgba(0, 0, 0, 0.4);
  --nsan-shadow-hover: 0 0 0 0.5px rgba(255, 255, 255, 0.16), 0 1px 3px rgba(0, 0, 0, 0.5);
  --nsan-focus: rgba(240, 138, 75, 0.55);
  color-scheme: dark;
}
.nsan-root *, .nsan-root *::before, .nsan-root *::after { box-sizing: border-box; }
.nsan-root [hidden] { display: none !important; }
:where(.nsan-root) button { margin: 0; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:where(.nsan-root) input, :where(.nsan-root) textarea, :where(.nsan-root) select { font: inherit; color: inherit; margin: 0; }
:where(.nsan-root) svg { display: block; flex: none; }
:where(.nsan-root) h2, :where(.nsan-root) h3, :where(.nsan-root) p, :where(.nsan-root) ul, :where(.nsan-root) ol, :where(.nsan-root) dl, :where(.nsan-root) dd { margin: 0; padding: 0; }
:where(.nsan-root) ul, :where(.nsan-root) ol { list-style: none; }
.nsan-root button:focus-visible, .nsan-root input:focus-visible, .nsan-root textarea:focus-visible, .nsan-root [tabindex]:focus-visible { outline: 2px solid var(--nsan-focus); outline-offset: 1px; }
.nsan-ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.nsan-app {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  height: 540px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--nsan-side);
  box-shadow: var(--nsan-shadow);
}

/* Sidomeny */
.nsan-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 10px 8px; }
.nsan-ws { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 6px; font-weight: 500; color: var(--nsan-strong); }
.nsan-ws-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nsan-ws-mark {
  display: grid; place-items: center; flex: none;
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--nsan-solid); color: var(--nsan-on-solid);
  font-size: 12px; font-weight: 600; line-height: 1;
}
.nsan-nav { display: flex; flex-direction: column; gap: 1px; }
.nsan-nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 30px; padding: 0 8px; border-radius: 6px;
  color: var(--nsan-text); text-align: left;
  transition: background-color 140ms ease, color 140ms ease;
}
.nsan-nav-item:hover { background: rgba(var(--nsan-k), 0.04); color: var(--nsan-ink); }
.nsan-nav-item[aria-current="page"] { background: var(--nsan-card); color: var(--nsan-strong); font-weight: 500; box-shadow: var(--nsan-shadow); }
.nsan-nav-item[aria-current="page"] .nsan-ico { color: var(--nsan-ember); }
.nsan-nav-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nsan-badge { font-size: 12px; line-height: 16px; color: var(--grey); font-variant-numeric: tabular-nums; }
.nsan-me { display: flex; align-items: center; gap: 8px; margin-top: auto; height: 32px; padding: 0 6px; color: var(--nsan-ink); font-weight: 500; }
.nsan-av {
  display: grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(var(--nsan-k), 0.07); color: var(--nsan-text);
  font-size: 12px; font-weight: 600; line-height: 1; letter-spacing: 0.02em;
}


.nsan-sec { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; }
.nsan-sec-l { padding: 0 8px 4px; font-size: 12px; line-height: 16px; color: var(--grey); }
.nsan-nav-item--sub { height: 28px; }
.nsan-nav-item--sub .nsan-ico { width: 15px; height: 15px; color: var(--grey); }
.nsan-goal { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding: 10px 10px 12px; border-radius: 9px; background: var(--nsan-card); box-shadow: var(--nsan-shadow); }
.nsan-goal-t { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--nsan-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsan-goal-s { font-size: 12px; line-height: 16px; color: var(--grey); font-variant-numeric: tabular-nums; white-space: nowrap; }
.nsan-goal-bar { display: block; height: 3px; margin-top: 7px; border-radius: 2px; background: var(--nsan-line); overflow: hidden; }
.nsan-goal-bar i { display: block; height: 100%; border-radius: 2px; background: var(--nsan-ember); }
.nsan-goal + .nsan-me { margin-top: 0; }

/* Huvudyta: ett vitt kort */
.nsan-main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  margin: 6px 6px 6px 0; border-radius: 10px;
  background: var(--nsan-card); box-shadow: var(--nsan-shadow);
  overflow: hidden;
}
.nsan-top {
  display: flex; align-items: center; gap: 8px; flex: none;
  height: 44px; padding: 0 14px;
  border-bottom: 0.5px solid var(--nsan-line);
}
.nsan-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; color: var(--grey); white-space: nowrap; overflow: hidden; }
.nsan-crumbs strong { font-weight: 500; color: var(--nsan-strong); overflow: hidden; text-overflow: ellipsis; }
.nsan-body { flex: 1; min-height: 0; overflow: auto; }

/* Knappar */
.nsan-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 28px; padding: 4px 10px; border-radius: 6px;
  background: var(--nsan-card); box-shadow: var(--nsan-shadow);
  font-weight: 500; white-space: nowrap; color: var(--nsan-ink);
  transition: background-color 140ms ease, box-shadow 140ms ease, transform 160ms var(--nsan-ease), opacity 140ms ease;
}
.nsan-btn:hover { box-shadow: var(--nsan-shadow-hover); }
.nsan-btn:active { transform: scale(0.97); }
.nsan-btn--solid { background: var(--nsan-solid); color: var(--nsan-on-solid); box-shadow: none; }
.nsan-btn--solid:hover { background: rgba(var(--nsan-k), 0.8); box-shadow: none; }
.nsan-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.nsan-btn .nsan-ico { width: 14px; height: 14px; }

.nsan-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; line-height: 16px; white-space: nowrap;
  background: rgba(var(--nsan-k), 0.05); color: var(--nsan-text);
}
.nsan-pill[data-tone="ok"] { background: var(--nsan-ok-tint); color: var(--nsan-ok); }
.nsan-pill[data-tone="ember"] { background: var(--nsan-ember-tint); color: var(--nsan-ember-ink); }
.nsan-pill[data-tone="wait"] { background: var(--nsan-wait-tint); color: var(--nsan-wait); }
.nsan-sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Smal bredd: sidomenyn blir en rad överst, ramen växer med innehållet */
@container (max-width: 600px) {
  .nsan-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
  .nsan-side { flex-direction: row; align-items: center; gap: 4px; padding: 6px 6px 0; overflow-x: auto; scrollbar-width: none; }
  .nsan-side::-webkit-scrollbar { display: none; }
  .nsan-ws-name, .nsan-me, .nsan-sec, .nsan-goal { display: none; }
  .nsan-ws { padding: 0 4px; }
  .nsan-nav { flex-direction: row; gap: 2px; }
  .nsan-nav-item { width: auto; padding: 0 8px; }
  .nsan-nav-label { overflow: visible; }
  .nsan-main { margin: 6px; }
  .nsan-top { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .nsan-root *, .nsan-root *::before, .nsan-root *::after { transition: none !important; animation: none !important; }
}

/* Analys: nyckeltal, stapeldiagram och fördelning */
.nsan-seg { display: inline-flex; padding: 2px; border-radius: 7px; background: rgba(var(--nsan-k), 0.045); }
.nsan-seg-opt { height: 24px; padding: 0 9px; border-radius: 5px; font-size: 12px; font-weight: 500; color: var(--nsan-text); white-space: nowrap; transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.nsan-seg-opt[aria-checked="true"] { background: var(--nsan-card); color: var(--nsan-strong); box-shadow: var(--nsan-shadow); }
.nsan-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.nsan-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.nsan-kpi { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; box-shadow: var(--nsan-shadow); min-width: 0; }
.nsan-kpi-l { font-size: 12px; line-height: 16px; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsan-kpi-v { font-size: 17px; line-height: 26px; font-weight: 500; letter-spacing: -0.01em; color: var(--nsan-strong); white-space: nowrap; }
.nsan-delta { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--nsan-ember-ink); }
.nsan-delta[data-good] { color: var(--nsan-ok); }
.nsan-swap { animation: nsan-swap 420ms var(--nsan-ease); }

.nsan-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 8px; flex: 1; min-height: 0; }
.nsan-row--low { flex: none; }
.nsan-row:not(.nsan-row--low) { flex: 1 0 auto; }
.nsan-meter { display: flex; flex-direction: column; gap: 8px; }
.nsan-meter li { display: grid; grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; column-gap: 8px; }
.nsan-meter span { color: var(--nsan-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsan-meter b { font-weight: 500; color: var(--nsan-ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nsan-meter i { grid-column: 1 / -1; display: block; height: 4px; border-radius: 2px; background: var(--nsan-line); overflow: hidden; }
.nsan-meter s { display: block; height: 100%; border-radius: 2px; background: rgba(var(--nsan-k), 0.5); transition: width 420ms var(--nsan-ease); }
.nsan-meter li:first-child s { background: var(--nsan-ember); }
.nsan-list--tight div { padding: 6px 0; }
.nsan-list--tight div:last-child { border-bottom: 0; }
.nsan-card { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; box-shadow: var(--nsan-shadow); min-width: 0; }
.nsan-card-h { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; color: var(--nsan-strong); margin-bottom: 8px; }
.nsan-tip { font-size: 12px; font-weight: 400; color: var(--grey); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nsan-tip[data-on] { color: var(--nsan-ink); font-weight: 500; }
.nsan-chart { position: relative; flex: 1; min-height: 168px; }
.nsan-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.nsan-grid line { stroke: var(--nsan-line); stroke-width: 1; }
.nsan-axis text { font-size: 12px; fill: var(--grey); font-family: var(--sans); }
.nsan-bar { fill: rgba(var(--nsan-k), 0.12); transition: fill 140ms ease; cursor: pointer; }
.nsan-bar[data-last] { fill: var(--nsan-ember); }
.nsan-bar:hover, .nsan-bar[data-hot] { fill: rgba(var(--nsan-k), 0.7); }
.nsan-bar[data-last]:hover, .nsan-bar[data-last][data-hot] { fill: var(--nsan-ember-ink); }
.nsan-bar:focus { outline: none; }
.nsan-bar:focus-visible { stroke: var(--nsan-focus); stroke-width: 2; }

.nsan-list div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 0.5px solid var(--nsan-line); }
.nsan-list dt { color: var(--nsan-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsan-list dd { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--nsan-ink); }
.nsan-list .nsan-total { border-bottom: 0; padding-top: 8px; }
.nsan-list .nsan-total dt, .nsan-list .nsan-total dd { color: var(--nsan-strong); font-weight: 500; }

@keyframes nsan-swap { from { opacity: 0.2; transform: translateY(3px); } }

@container (max-width: 600px) {
  .nsan-top { flex-wrap: wrap; height: auto; min-height: 44px; padding-top: 8px; padding-bottom: 8px; }
  .nsan-export { display: none; }
  .nsan-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nsan-row { grid-template-columns: minmax(0, 1fr); }
  .nsan-chart { min-height: 170px; }
}

/* Inga bokstavsavatarer: namnet står som text */
.nsan-ws-mark, .nsan-av { display: none !important; }
