/* ===== cloudsaver — simplified design tokens ===== */
:root {
  --bg: #fafbfc;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #eaeef3;
  --border: #e8ecf1;
  --border-strong: #d8dee6;
  --text: #0f1822;
  --text-2: #495668;
  --text-3: #7b8896;
  --text-4: #a4afbe;

  --accent-h: 195;
  --accent: oklch(0.6 0.13 var(--accent-h));
  --accent-strong: oklch(0.5 0.15 var(--accent-h));
  --accent-soft: oklch(0.97 0.022 var(--accent-h));
  --accent-tint: oklch(0.93 0.04 var(--accent-h));
  --accent-bg: oklch(0.95 0.03 var(--accent-h));  /* gentle fill, e.g. selected row, action bar */
  --accent-fg: #ffffff;
  --btn-primary: var(--accent-strong);            /* WCAG: #007b7e on white = 5.08:1 (AA) */
  --btn-primary-hover: oklch(0.43 0.15 var(--accent-h));

  --pos: oklch(0.6 0.13 155);
  --pos-soft: oklch(0.97 0.025 155);
  --warn: oklch(0.7 0.15 70);
  --warn-soft: oklch(0.97 0.04 70);
  --neg: oklch(0.6 0.18 25);
  --neg-soft: oklch(0.97 0.03 25);
  --warn-bg: oklch(0.98 0.03 70);   /* banner/alert background — warm yellow tint */

  /* Categorical data colors — "Var slöseriet finns" (neon signal set, max hue separation) */
  --cat-licenses: #f4ab00; --cat-licenses-ink: #a86a00;  /* guld — spend */
  --cat-versions: #8b3ae5; --cat-versions-ink: #7b2fd0;  /* violett — data/filer */
  --cat-storage:  #009adb; --cat-storage-ink:  #0079a8;  /* azur — infrastruktur */
  --cat-azure:    #e7224a; --cat-azure-ink:    #d11d43;  /* crimson — kräver åtgärd */

  /* Theme-invariant utility colors (identical in light & dark by design) */
  --fixed-white: #ffffff;   /* text/icons on saturated brand or fixed-dark surfaces */
  --glass-accent: #6ab0ff;  /* control accent on fixed-dark glass overlays */

  /* Data-viz heat scale — version-count / file-age intensity (cool → hot) */
  --heat-1: #06b6d4; --heat-2: #22c55e; --heat-3: #eab308; --heat-4: #f97316; --heat-5: #ef4444;
  --heat-amber: #f59e0b;    /* amber mid-stop for the fresh→cold age gradient */

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 24, 34, 0.04);
  --shadow-md: 0 6px 18px -8px rgba(15, 24, 34, 0.1);
  --shadow-lg: 0 24px 60px -16px rgba(15, 24, 34, 0.18);

  --pad-card: 24px;
  --pad-row: 14px 18px;
  --gap: 18px;

  /* Type scale — snap every size to these; no half-pixels */
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px;
  --fs-md: 15px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 20px;
  --fs-3xl: 24px; --fs-4xl: 30px; --fs-5xl: 40px; --fs-6xl: 60px;

  /* Weight roles */
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  /* Spacing scale — 4-pt grid */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;

  /* Radius + motion */
  --radius-pill: 999px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.12s var(--ease);
  --transition: 0.2s var(--ease);
}

[data-theme="dark"] {
  --bg: #0a1018;
  --surface: #10181f;
  --surface-2: #161f28;
  --surface-3: #1d2832;
  --border: #1f2a36;
  --border-strong: #2b3645;
  --text: #e6edf5;
  --text-2: #a8b6c5;
  --text-3: #7d8b9d;
  --text-4: #5a6878;

  --accent: oklch(0.72 0.13 var(--accent-h));
  --accent-strong: oklch(0.8 0.13 var(--accent-h));
  --accent-soft: oklch(0.26 0.05 var(--accent-h));
  --accent-tint: oklch(0.32 0.07 var(--accent-h));
  --accent-bg: oklch(0.28 0.06 var(--accent-h));
  --accent-fg: #06121c;
  --btn-primary: var(--accent);                   /* bright teal on dark surface */
  --btn-primary-hover: var(--accent-strong);

  --pos: oklch(0.74 0.14 155);
  --pos-soft: oklch(0.26 0.05 155);
  --warn: oklch(0.78 0.13 70);
  --warn-soft: oklch(0.28 0.06 70);
  --neg: oklch(0.72 0.16 25);
  --neg-soft: oklch(0.26 0.05 25);
  --warn-bg: oklch(0.24 0.05 70);   /* dark-mode banner background */

  /* Categorical data colors — brighter on dark surfaces; glyph ink = full color */
  --cat-licenses: #fdba2f; --cat-licenses-ink: #fdba2f;
  --cat-versions: #a45eff; --cat-versions-ink: #a45eff;
  --cat-storage:  #00b7f3; --cat-storage-ink:  #00b7f3;
  --cat-azure:    #f8495f; --cat-azure-ink:    #f8495f;

  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.02);
  --shadow-md: 0 6px 18px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, 0.6);
}

[data-density="compact"] {
  --pad-card: 16px;
  --pad-row: 9px 14px;
  --gap: 12px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01", "ss03";
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum", "zero"; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================== App shell ============================== */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  min-height: 700px;
  background: var(--bg);
}
.app[data-collapsed="true"] { grid-template-columns: 64px 1fr; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 22px 20px;
  height: 72px;
}
.sb-logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  display: grid; place-items: center;
  color: var(--accent-fg);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.sb-name {
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.015em;
  white-space: nowrap;
}
.sb-name b { color: var(--accent); font-weight: 650; }

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 16px;
}
.sb-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px 4px;
  margin-top: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  font-family: inherit;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.sb-group-header:hover { color: var(--text-2); }

.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  margin-bottom: 1px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 550;
  box-shadow: inset 3px 0 0 var(--accent-strong);
}
[data-theme="dark"] .sb-item[aria-current="true"] {
  color: var(--accent-strong);
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent-strong);
}

.sb-org {
  margin: 0 12px 8px;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.sb-org:hover { background: var(--surface-2); }
.sb-org-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--surface-3);
  display: grid; place-items: center;
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.sb-org-meta { flex: 1; min-width: 0; }
.sb-org-name { font-weight: 550; font-size: 13px; }
.sb-org-tier { font-size: 11.5px; color: var(--text-3); }

.sb-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 11px;
}
.sb-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.7 0.12 280), oklch(0.65 0.13 320));
  color: white;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
}
.sb-user-name { font-size: 13px; font-weight: 550; }
.sb-user-email { font-size: 11.5px; color: var(--text-3); }

/* ============================== Topbar ============================== */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  height: 72px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 20px;
  flex-shrink: 0;
}
.tb-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  width: 320px;
  color: var(--text-3);
  cursor: text;
}
.tb-search:hover { border-color: var(--border-strong); }
.tb-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.tb-search kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-3);
}
.tb-actions { display: flex; align-items: center; gap: 4px; }
.tb-iconbtn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tb-iconbtn:hover { background: var(--surface-2); color: var(--text); }
.tb-iconbtn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--neg);
  border: 2px solid var(--surface);
}

/* ============================== Page canvas ============================== */
.canvas {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 60px;
}
.canvas-inner { max-width: 1320px; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 24px;
  flex-wrap: wrap;
}
.page-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 6px;
}
.page-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
  font-family: var(--font-sans);
}
.page-sub {
  color: var(--text-3);
  font-size: var(--fs-base);
  max-width: 600px;
}
.page-actions { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: background var(--transition-fast);
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--btn-primary);
  color: var(--accent-fg);
  border-color: var(--btn-primary);
}
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: var(--fs-sm); }
.btn:focus-visible, .tb-iconbtn:focus-visible,
.sb-item:focus-visible, .sb-org:focus-visible, .seg button:focus-visible,
.modal-result:focus-visible, .tb-search:focus-visible, .waste:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Form controls */
.input {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}
.input:focus { border-color: var(--accent); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.input:hover { border-color: var(--border-strong); }
.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-2xs);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.pill-pos { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-neg { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.pill-accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid color-mix(in oklch, var(--border) 78%, var(--accent-tint));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--pad-card); }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--pad-card) var(--pad-card) 0;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
.card-sub { font-size: var(--fs-sm); color: var(--text-3); margin-top: 5px; }
.card-body { padding: var(--pad-card); }

/* Grids */
.grid { display: grid; gap: var(--gap); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-8, .span-7, .span-6, .span-5, .span-4, .span-3 { grid-column: span 12; }
}

/* Hero KPI */
.hero {
  background: var(--surface);
  border: 1px solid color-mix(in oklch, var(--border) 78%, var(--accent-tint));
  border-radius: var(--radius-lg);
  padding: 34px 38px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -1px;
  background: radial-gradient(800px 200px at 100% 0%, var(--accent-soft), transparent 60%);
  pointer-events: none;
  opacity: 0.9;
}
.hero-eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}
.hero-value {
  font-size: 60px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-sans);
}
.hero-value .unit { font-size: 22px; color: var(--text-3); font-weight: 500; }
.hero-foot {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}

/* KPI tile (smaller) */
.kpi { padding: var(--pad-card); }
.kpi-label {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 550;
  margin-bottom: 14px;
}
.kpi-value {
  font-size: 32px;
  font-weight: 650;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.1;
}
.kpi-value-unit { font-size: 14px; color: var(--text-3); font-weight: 500; }
.kpi-foot {
  margin-top: 12px;
  font-size: var(--fs-sm);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.kpi-delta.pos { color: var(--pos); }
.kpi-delta.neg { color: var(--neg); }

/* Waste card — the core unit of the redesign */
.waste {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--pad-card);
  background: var(--surface);
  border: 1px solid color-mix(in oklch, var(--border) 78%, var(--accent-tint));
  border-radius: var(--radius);
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.waste:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.waste-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  margin-bottom: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.waste-icon.warn { background: var(--warn-soft); color: var(--warn); }
.waste-icon.neg  { background: var(--neg-soft); color: var(--neg); }
.waste-icon.pos  { background: var(--pos-soft); color: var(--pos); }
.waste-icon.cat-licenses { background: color-mix(in srgb, var(--cat-licenses) 16%, transparent); color: var(--cat-licenses-ink); }
.waste-icon.cat-versions { background: color-mix(in srgb, var(--cat-versions) 16%, transparent); color: var(--cat-versions-ink); }
.waste-icon.cat-storage  { background: color-mix(in srgb, var(--cat-storage) 16%, transparent); color: var(--cat-storage-ink); }
.waste-icon.cat-azure    { background: color-mix(in srgb, var(--cat-azure) 16%, transparent); color: var(--cat-azure-ink); }
.waste-label { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; letter-spacing: 0.01em; }
.waste-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.026em;
  margin: 3px 0 7px;
  font-variant-numeric: tabular-nums;
}
.waste-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}
.waste-foot b { color: var(--pos); font-weight: 600; }

/* Tables */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
.table thead th {
  text-align: left;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: var(--pad-row);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.table tbody td {
  padding: var(--pad-row);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 13px; }
.table .right { text-align: right; }
.table .check { width: 36px; }

/* Bar */
.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-fill.pos { background: var(--pos); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.neg { background: var(--neg); }

/* Avatar */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 11px;
  color: white;
  flex-shrink: 0;
}
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }

/* User stack avatars */
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* Service badge */
.svc {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: inline-grid; place-items: center;
  font-weight: 700;
  font-size: 10px;
  color: white;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.svc-365 { background: linear-gradient(135deg, #d83b01, #a52600); }
.svc-blob { background: linear-gradient(135deg, #1976d2, #0d47a1); }
.svc-files { background: linear-gradient(135deg, #00838f, #006064); }
.svc-anf    { background: linear-gradient(135deg, #00bfa5, #00695c); }
.svc-qumulo { background: linear-gradient(135deg, #6a1b9a, #4a148c); }
.svc-s3 { background: linear-gradient(135deg, #e8590c, #b53d00); }

/* Segmented */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--text-2);
  padding: 5px 12px;
  font-size: var(--fs-sm);
  font-weight: 550;
  border-radius: 4px;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.seg-wrap {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: 4px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 550;
  color: var(--text-3);
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 3px; }

/* License plan badge */
.plan {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
  white-space: nowrap;
}
.plan-e5 { background: oklch(0.94 0.05 280); color: oklch(0.4 0.18 280); }
.plan-e3 { background: var(--accent-soft); color: var(--accent-strong); }
.plan-e1 { background: var(--surface-3); color: var(--text-2); }
.plan-business { background: var(--pos-soft); color: var(--pos); }
[data-theme="dark"] .plan-e5 { background: oklch(0.28 0.07 280); color: oklch(0.85 0.13 280); }
[data-theme="dark"] .plan-e1 { background: var(--surface-3); color: var(--text-2); }

/* Status dot */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.status-dot.live { background: var(--pos); box-shadow: 0 0 0 3px color-mix(in oklch, var(--pos) 25%, transparent); }
.status-dot.warn { background: var(--warn); }
.status-dot.idle { background: var(--text-4); }

/* Check box */
.check-box {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  display: inline-grid; place-items: center;
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}
.check-box[data-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  /* Always use the brand accent (blue) so the toast is legible in both light and
     dark themes — previously used var(--text)/var(--bg) which rendered as a white
     pill in dark mode. */
  background: var(--accent);
  color: var(--accent-fg);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Modal */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(15, 24, 34, 0.4);
  display: grid; place-items: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
[data-theme="dark"] .modal-back { background: rgba(0, 0, 0, 0.6); }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 600px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Search modal components */
.modal-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.modal-search-kbd {
  font-size: 10.5px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-3);
}
.modal-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}
.modal-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}
.modal-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.modal-result:hover { background: var(--surface-2); }
.modal-result-pill { min-width: 70px; justify-content: center; }
.modal-result-meta { flex: 1; }
.modal-result-label { font-weight: 550; font-size: 13.5px; }
.modal-result-ctx { font-size: 12px; color: var(--text-3); }

/* Empty / muted */
.muted { color: var(--text-3); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* Scrollbar */
.menu-item:hover { background: var(--surface-2); }

/* Hue slider — full-spectrum picker used in Settings */
.hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: hsl(var(--accent-h), 70%, 50%);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.18);
  cursor: grab;
}
.hue-slider::-webkit-slider-thumb:active { cursor: grabbing; }
.hue-slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: hsl(var(--accent-h), 70%, 50%);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.18);
  cursor: grab;
}
[data-theme="dark"] .hue-slider::-webkit-slider-thumb,
[data-theme="dark"] .hue-slider::-moz-range-thumb {
  border-color: var(--surface);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.5);
}

.canvas::-webkit-scrollbar, .sb-nav::-webkit-scrollbar { width: 10px; height: 10px; }
.canvas::-webkit-scrollbar-thumb, .sb-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }
.canvas::-webkit-scrollbar-track, .sb-nav::-webkit-scrollbar-track { background: transparent; }

/* ============================== Responsive ============================== */
/* Off-canvas drawer backdrop — only rendered on mobile when the nav is open. */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 24, 34, 0.5);
  backdrop-filter: blur(2px);
  z-index: 190;
  animation: backdropIn 0.2s ease-out;
}
[data-theme="dark"] .sidebar-backdrop { background: rgba(0, 0, 0, 0.6); }
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

/* Tablet — tighten chrome and collapse multi-column grids to a comfortable width. */
@media (max-width: 1100px) {
  .topbar { padding: 0 20px; }
  .tb-search { width: 220px; }
  .canvas { padding: 28px 24px 56px; }
  .hero { padding: 28px 26px; }
  .hero-value { font-size: 48px; }
}

/* Phone — sidebar becomes an off-canvas drawer; everything collapses to one column. */
@media (max-width: 768px) {
  .app,
  .app[data-collapsed="true"] { grid-template-columns: 1fr; }

  /* Sidebar slides in from the left over the canvas; the App toggles
     [data-mobile-nav="open"] from the topbar hamburger. */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 274px;
    max-width: 84vw;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }
  .app[data-mobile-nav="open"] .sidebar { transform: translateX(0); }

  .topbar {
    height: 60px;
    padding: 0 12px;
    gap: 10px;
  }
  .tb-search { display: none; }

  .canvas { padding: 18px 16px 48px; }

  .page-head { margin-bottom: 22px; gap: 14px; }
  .page-title { font-size: 23px; }
  .page-sub { font-size: 13.5px; }
  .page-actions { flex-wrap: wrap; }

  .hero { padding: 22px 20px; border-radius: var(--radius); }
  .hero-value { font-size: 40px; }
  .hero-value .unit { font-size: 17px; }

  /* All multi-column layouts stack on a phone. */
  .grid-2,
  .grid-4,
  .grid-12 { grid-template-columns: minmax(0, 1fr); }
  .span-8, .span-7, .span-6, .span-5, .span-4, .span-3 { grid-column: 1 / -1; }

  /* Components set grid columns/spans via inline styles, which outrank class rules.
     Collapse every inline grid inside the canvas to a single column on phones and
     neutralise inline column spans so nothing forces a wider implicit track.
     minmax(0,1fr) + min-width:0 lets tracks shrink below their content min-content. */
  .canvas [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .canvas [style*="grid-column"] { grid-column: auto !important; }
  .canvas .grid > *,
  .canvas [style*="grid-template-columns"] > * { min-width: 0; }

  /* Never let the page body slide sideways — content stays pinned to the viewport. */
  .main,
  .canvas { overflow-x: hidden; }

  /* Wide tables stay reachable: any card holding a table becomes its own horizontal
     scroll container instead of bursting the layout. Covers tables with or without
     the .table class. */
  .card:has(table),
  .card-pad:has(table),
  .card-body:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Stacked tables never scroll sideways — their host card stays static. */
  .card:has(table.stack-cards),
  .card-pad:has(table.stack-cards),
  .card-body:has(table.stack-cards) { overflow-x: visible; }

  /* Flagged-users table → stacked cards on phones. An 8-column table is unreadable at
     360px even with horizontal scroll, so collapse each row into a labelled card. The
     card here is display:block so it never triggers the .card overflow-x scroll above. */
  #license-user-table:has(table) { overflow-x: visible; }
  #license-user-table .table,
  #license-user-table .table tbody,
  #license-user-table .table tr,
  #license-user-table .table td { display: block; width: 100%; }
  #license-user-table .table thead { display: none; }
  #license-user-table .table tbody tr {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px 14px;
    margin-bottom: 12px;
    background: var(--surface);
  }
  #license-user-table .table tbody tr:hover { background: var(--surface); }
  #license-user-table .table tbody tr:last-child td { border-bottom: none; }
  #license-user-table .table td {
    border: none !important;
    padding: 5px 0 !important;
    text-align: left !important;
    font-size: 13px;
  }
  /* key : value rows — uppercase label inline, value flows after */
  #license-user-table .table td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 108px;
    padding-right: 10px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    font-weight: 650;
    vertical-align: top;
  }
  /* num cells lose their right alignment — the label carries the meaning */
  #license-user-table .table td.num { text-align: left !important; }
  /* User cell = card header (no label, full width, room for the checkbox at top-right) */
  #license-user-table .table td.cell-user { padding: 2px 34px 6px 0 !important; }
  /* Checkbox tucks into the card's top-right corner */
  #license-user-table .table td.cell-check {
    position: absolute;
    top: 12px; right: 12px;
    width: auto;
    padding: 0 !important;
  }
  /* Status note wraps under the label rather than running off-screen */
  #license-user-table .table td.cell-status > div { display: block; }
  /* Action button spans the full card width at the bottom */
  #license-user-table .table td.cell-action { padding-top: 10px !important; text-align: left !important; }
  #license-user-table .table td.cell-action .btn { width: 100%; }

  /* Generic wide-table → stacked cards. app-shell tags wide data tables with
     .stack-cards and copies each column header into the cell's data-label, so any
     multi-column table (guests, Azure resources, data age, versions…) becomes a
     readable list of labelled key/value rows instead of a sideways-scrolling grid. */
  .table.stack-cards { display: block; width: 100%; }
  .table.stack-cards thead { display: none; }
  .table.stack-cards tbody { display: block; }
  .table.stack-cards tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--surface);
  }
  .table.stack-cards tbody tr:hover { background: var(--surface); }
  .table.stack-cards td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    width: auto !important;
    border: none !important;
    padding: 6px 0 !important;
    text-align: right !important;
    font-size: 13px;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .table.stack-cards td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 45%;
    font-size: 10.5px;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-3);
    font-weight: 650;
    text-align: left;
  }
  /* Unlabelled cells (leading checkbox, trailing action button) span the row. */
  .table.stack-cards td:not([data-label]) { justify-content: flex-start; text-align: left !important; }
  .table.stack-cards td:not([data-label]) .btn { width: 100%; }

  /* Button / action rows wrap rather than overflow. */
  .page-actions,
  .card-head,
  .seg-wrap { flex-wrap: wrap; }

  /* Scrollable tab + segmented controls so they never overflow the viewport. */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }
  .seg-wrap { justify-content: flex-start; }

  /* Modals and toasts fit the smaller viewport. */
  .modal {
    width: 100%;
    max-width: 94vw;
    max-height: 92vh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-back { padding: 16px; }
  /* Multi-column tier/plan grids inside modals stack into one column on phones. */
  .plan-tier-grid { grid-template-columns: 1fr !important; }
  .toast { left: 16px; right: 16px; bottom: 16px; transform: none; }
  @keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Larger touch targets for nav + icon buttons. */
  .sb-item { padding: 11px 12px; font-size: 15px; }
  .tb-iconbtn { width: 40px; height: 40px; }
  .kpi-value { font-size: 28px; }
}

/* ============================================================================
   RESPONSIVE HARDENING — narrow-desktop / tablet band (769–1199px)
   ----------------------------------------------------------------------------
   The layout is tuned for ≥1300px desktop and ≤768px mobile. In between, dense
   rows kept their desktop column counts without the width to hold them, so the
   two Overview hero numbers collided, KPI values wrapped, the data-age tiles
   broke onto multiple lines and the donut legend crowded. These rules relax
   those rows in that band only — the desktop and mobile layouts are untouched.
   ============================================================================ */
@media (min-width: 769px) and (max-width: 1199px) {
  /* Overview hero: stack the two value panes (mirrors the mobile layout) so two
     no-wrap currency figures never have to share one short row. */
  .hero > div { flex-direction: column !important; gap: 18px !important; }
  .hero > div > div[style*="width: 1px"] { width: 100% !important; height: 1px !important; }
  .hero-value { font-size: 32px !important; }

  /* Dense inline grids (hero + donut row, KPI / source cards, data-age tiles)
     collapse to two columns and inline column-spans cap at two, so no pane is
     forced narrower than its content can render. */
  .canvas [style*="grid-template-columns: repeat"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .canvas [style*="grid-column: span"] { grid-column: span 2 !important; }
  .canvas [style*="grid-template-columns"] > * { min-width: 0; }

  /* Two-column content grids (e.g. Licenses "By plan" / "By waste category")
     stack to one column in the narrow band so their dense internal rows
     — like "…477 kr/mån wasted   48/55 seats" — get full width and never
     overlap. At full desktop width these stay side-by-side, untouched. */
  .grid-2 { grid-template-columns: minmax(0, 1fr); }

  /* Wide tables get their own horizontal scroll instead of clipping their
     right-most column (e.g. the Restore "Download" action). Stacked-card
     tables are excluded — they intentionally never scroll sideways. */
  .card:has(table):not(:has(table.stack-cards)),
  .card-pad:has(table):not(:has(table.stack-cards)),
  .card-body:has(table):not(:has(table.stack-cards)) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Tab bars (Settings, Licenses, etc.) scroll horizontally instead of clipping
     their trailing tabs (e.g. "Rapporter") where the row is wider than the band. */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }
}

/* Break long path / file strings at sensible points rather than mid-word
   (e.g. "Build_artifacts.zip"), at every width. overflow-wrap:anywhere only
   breaks when a break is actually needed, so normal cells are unaffected. */
.table td, .table th { overflow-wrap: anywhere; }

/* Pills / badges stay on one line — a narrow column used to wrap labels like
   the "Azure Management" API badge onto a second row. */
.pill,
.canvas span[style*="border-radius: 999px"] { white-space: nowrap; }

/* =============================================================================
   Consumeit · "Slate + Signal" theme  (appended — overrides the tokens above)
   Dark-slate / cyan / green-amber-red palette from the audit roadmap, mapped
   onto the existing design tokens. Only colours are overridden; radii, spacing,
   fonts and the oklch accent-hue machinery are untouched.
   ============================================================================= */

/* ---- LIGHT MODE -------------------------------------------------------------
   Coherent daytime companion: same cyan accent, same signal trio, slate neutrals. */
:root {
  --bg:            #f6f8fa;
  --surface:       #ffffff;
  --surface-2:     #f1f4f8;
  --surface-3:     #e7edf3;
  --border:        #e6ebf0;
  --border-strong: #d4dbe3;

  --text:   #0f1822;
  --text-2: #475467;
  --text-3: #7b8896;
  --text-4: #a4afbe;

  /* Accent — hue-driven (oklch) so the accent-hue slider recolors live */
  --accent-h:      195;
  --accent:        oklch(0.6 0.13 var(--accent-h));
  --accent-strong: oklch(0.5 0.15 var(--accent-h));
  --accent-soft:   oklch(0.97 0.022 var(--accent-h));
  --accent-tint:   oklch(0.93 0.04 var(--accent-h));
  --accent-bg:     oklch(0.95 0.03 var(--accent-h));
  --accent-fg:     #ffffff;

  /* Signal trio: green / amber / red */
  --pos:       #0d9f6e;
  --pos-soft:  #e8f8f1;
  --warn:      #dd9418;
  --warn-soft: #fbf3e3;
  --warn-bg:   #fdf6e9;
  --neg:       #e0524b;
  --neg-soft:  #fbeceb;
}

/* ---- DARK MODE (the hero look from the roadmap) ---------------------------- */
[data-theme="dark"] {
  --bg:            #0f1822;  /* signature slate */
  --surface:       #141f2b;
  --surface-2:     #1a2733;
  --surface-3:     #22303d;
  --border:        #1f2b38;
  --border-strong: #2b3a49;

  --text:   #f5f7fa;
  --text-2: #c2cbd6;
  --text-3: #8b98a8;
  --text-4: #5f6e7e;

  --accent-h:      195;
  --accent:        oklch(0.72 0.13 var(--accent-h));
  --accent-strong: oklch(0.8 0.13 var(--accent-h));
  --accent-soft:   oklch(0.26 0.05 var(--accent-h));
  --accent-tint:   oklch(0.32 0.07 var(--accent-h));
  --accent-bg:     oklch(0.28 0.06 var(--accent-h));
  --accent-fg:     #06121c;

  --pos:       #34d39a;  /* green   — realized savings, success */
  --pos-soft:  #10271f;
  --warn:      #f7b34d;  /* amber   — attention, pending */
  --warn-soft: #2a2012;
  --warn-bg:   #241c10;
  --neg:       #f87a72;  /* red     — critical, destructive */
  --neg-soft:  #2a1715;

  /* Soft shadows that read on dark */
  --shadow-sm: 0 1px 0 rgba(255,255,255,.03);
  --shadow-md: 0 6px 18px -8px rgba(0,0,0,.55);
  --shadow-lg: 0 24px 60px -16px rgba(0,0,0,.62);
}

/* ---- Optional: status-timeline accent borders (the roadmap treatment) -------
   Utility classes for the green/amber/cyan left-border "phase" rows you liked.
   Use e.g. <div class="phase phase--now"> … </div> */
.phase            { border-left: 3px solid var(--border-strong); padding-left: 18px; }
.phase--now       { border-left-color: var(--pos); }
.phase--next      { border-left-color: var(--warn); }
.phase--later     { border-left-color: var(--accent); }

