:root {
  /*
    Colors

    Ditch hex for HSL
    Hex and RGB are the most common formats for representing color on the web, but they’re not the most useful.
    Using hex or RGB, colors that have a lot in common visually look nothing alike in code.
    HSL fixes this by representing colors using attributes the human-eye intuitively perceives: hue, saturation, and lightness.

    Where a color is defined in the brand guidelines, it's referenced it in a comment.
   */
  --primary-color050: hsla(24, 100%, 96%, 1);
  --primary-color100: hsla(20, 96%, 90%, 1);
  --primary-color200: hsla(21, 95%, 83%, 1);
  --primary-color300: hsla(21, 95%, 76%, 1);
  --primary-color400: hsla(21, 95%, 68%, 1);
  --primary-color500: hsla(21, 95%, 56%, 1); /* 'KG Orange' */
  --primary-color600: hsla(21, 82%, 51%, 1);
  --primary-color700: hsla(21, 60%, 37%, 1);
  --primary-color800: hsla(21, 61%, 24%, 1);
  --primary-color900: hsla(21, 61%, 12%, 1);
  --primary-color500-trans: hsla(21, 95%, 56%, 0.5);

  --neutral-color050: hsl(216, 33%, 97%);
  --neutral-color100: hsl(214, 15%, 91%);
  --neutral-color200: hsl(210, 16%, 82%);
  --neutral-color300: hsl(211, 13%, 65%);
  --neutral-color400: hsl(211, 10%, 53%);
  --neutral-color500: hsl(211, 12%, 43%);
  --neutral-color600: hsl(209, 14%, 37%);
  --neutral-color680-trans: hsla(209, 14%, 30%, 0.5);
  --neutral-color700: hsl(209, 15%, 28%);
  --neutral-color800: hsl(210, 18%, 22%); /* Charcoal */
  --neutral-color850: hsl(210, 17%, 20%);
  --neutral-color900: hsl(207, 16%, 17%);
  --neutral-color900-trans: hsla(207, 16%, 17%, 0.7);

  --white-color: white;
  --grey-color-50: hsla(240, 7%, 98%, 1);
  --grey-color-100: hsla(240, 7%, 97%, 1);
  --grey-color-100-trans: hsla(240, 7%, 97%, 0.9);
  --grey-color-200: hsla(240, 6%, 90%, 1);
  --grey-color-200-trans: hsla(240, 6%, 90%, 0.9);
  --grey-color-300: hsla(240, 3%, 72%, 1);
  --grey-color-300-trans: hsla(240, 3%, 72%, 0.9);

  --supporting-color050: hsl(45, 100%, 96%);
  --supporting-color100: hsl(45, 90%, 88%);
  --supporting-color200: hsl(45, 86%, 81%);
  --supporting-color300: hsl(43, 90%, 76%);
  --supporting-color400: hsl(43, 89%, 70%);
  --supporting-color500: hsl(42, 78%, 60%);
  --supporting-color600: hsl(42, 63%, 48%);
  --supporting-color700: hsl(43, 72%, 37%);
  --supporting-color800: hsl(43, 77%, 27%);
  --supporting-color900: hsl(43, 86%, 17%);

  /*
    We have only defined one accent color.
    This is ok for now, as we only need one shade,
    but at some point in the future we
    will want to define the whole range.
  */
  --accent-color050: hsl(152, 68%, 96%);
  --accent-color100: hsl(154, 75%, 87%);
  --accent-color200: hsl(156, 73%, 74%);
  --accent-color300: hsl(158, 58%, 62%);
  --accent-color400: hsl(160, 51%, 49%);
  --accent-color500: hsl(162, 63%, 41%);
  --accent-color600: hsl(164, 71%, 34%);
  --accent-color700: hsl(166, 72%, 28%);
  --accent-color800: hsl(168, 80%, 23%);
  --accent-color900: hsl(170, 97%, 15%);

  --error-color050: hsl(0, 100%, 95%);
  --error-color100: hsl(0, 100%, 87%);
  --error-color200: hsl(0, 100%, 80%);
  --error-color300: hsl(0, 91%, 69%);
  --error-color400: hsl(0, 83%, 62%);
  --error-color500: hsl(356, 75%, 53%);
  --error-color600: hsl(354, 85%, 44%);
  --error-color700: hsl(352, 90%, 35%);
  --error-color800: hsl(350, 94%, 28%);
  --error-color900: hsl(348, 94%, 20%);

  --brand-linear-gradient: 153deg, var(--primary-color600) 0, var(--primary-color500) 42%,
    var(--supporting-color400) 75%, var(--supporting-color300) 100%;
  --unauthenticated-background-color: var(--primary-color500);

  --floating-banner-color: var(--error-color050);
  /*
    This is actually hard-coded in the patterns.css file.
    TODO(P3/S): interpolate this value in the the background-image prop, used by the bg patters.
   */
  --unauthenticated-palette-color: hsl(0, 41%, 49%);

  /*
    Spacing system
  */
  --ratio: 1.5;
  --s-6: calc(var(--s-5) / var(--ratio));
  --s-5: calc(var(--s-4) / var(--ratio));
  --s-4: calc(var(--s-3) / var(--ratio));
  --s-3: calc(var(--s-2) / var(--ratio));
  --s-2: calc(var(--s-1) / var(--ratio));
  --s-1: calc(var(--s0) / var(--ratio));
  --s0: 1rem;
  --s1: calc(var(--s0) * var(--ratio));
  --s2: calc(var(--s1) * var(--ratio));
  --s3: calc(var(--s2) * var(--ratio));
  --s4: calc(var(--s3) * var(--ratio));
  --s5: calc(var(--s4) * var(--ratio));
  --s6: calc(var(--s5) * var(--ratio));
  --s7: calc(var(--s6) * var(--ratio));
  --s8: calc(var(--s7) * var(--ratio));

  --spacer-7xs: 4px;
  --spacer-6xs: 8px;
  --spacer-5xs: 12px;
  --spacer-4xs: 16px;
  --spacer-3xs: 20px;
  --spacer-2xs: 24px;
  --spacer-xs: 32px;
  --spacer-2xl: 80px;

  --border-radius: var(--s0);
  --border-large-radius: var(--s0);
  --border-thin: 1px;
  --border-menu: var(--s-6);
  --border-thick: var(--s-1);
  --border-default: var(--s-4);

  line-height: var(--ratio);

  --font-color: var(--neutral-color900);

  --font-size-scale: 1.2;
  --font-size-code: calc(0.8rem * var(--font-size-scale));
  --font-size-tag: calc(0.9rem * var(--font-size-scale));
  --font-size-caption: calc(0.85rem * var(--font-size-scale));
  --font-size-about: calc(0.8rem * var(--font-size-scale));
  --font-size-info: calc(0.7rem * var(--font-size-scale));
  --font-size-menu: calc(0.9rem * var(--font-size-scale));
  --font-size-body: calc(1rem * var(--font-size-scale));
  --font-size-body-large: calc(1.1rem * var(--font-size-scale));
  --font-size-h6: calc(1.15rem * var(--font-size-scale));
  --font-size-h5: calc(1.22rem * var(--font-size-scale));
  --font-size-h4: calc(1.3rem * var(--font-size-scale));
  --font-size-h3: calc(1.6rem * var(--font-size-scale));
  --font-size-h2: calc(1.9rem * var(--font-size-scale));
  --font-size-h1: calc(2.35rem * var(--font-size-scale));

  --font-size-s: calc(20px * var(--font-size-scale));
  --font-size-3xs: calc(15px * var(--font-size-scale));

  --font-color-h6: var(--neutral-color900);
  --font-color-h5: var(--neutral-color900);
  --font-color-h4: var(--neutral-color900);
  --font-color-h3: var(--neutral-color900);

  --font-weight-caption: var(--font-weight-regular);
  --font-weight-body: var(--font-weight-regular);
  --font-weight-body-large: var(--font-weight-regular);
  --font-weight-h6: var(--font-weight-medium);
  --font-weight-h5: var(--font-weight-medium);
  --font-weight-h4: var(--font-weight-regular);
  --font-weight-h3: var(--font-weight-light);
  --font-weight-h2: var(--font-weight-light);
  --font-weight-h1: var(--font-weight-light);

  --line-height-caption: 150%;
  --line-height-body: 1;
  --line-height-body-large: 1;
  --line-height-h6: 1;
  --line-height-h5: 1;
  --line-height-h4: 1;
  --line-height-h3: 1;
  --line-height-h2: 1.1;
  --line-height-h1: 1;

  --letter-spacing-caption: 0;
  --letter-spacing-body: 0;
  --letter-spacing-body-large: 0;
  --letter-spacing-h6: 0;
  --letter-spacing-h5: 0;
  --letter-spacing-h4: 0;
  --letter-spacing-h3: 0;
  --letter-spacing-h2: 0;
  --letter-spacing-h1: 0;

  --font-weight-light: 100;
  --font-weight-regular: 400;
  --font-weight-medium: 400;
  --font-weight-heavy: 700;

  --font-family-heading: 'Everett', Arial, sans-serif;
  --font-family-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-family-monospace: 'PT Mono', monospace;

  --box-shadow-0: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --box-shadow-1: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --box-shadow-2: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --box-shadow-3: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --box-shadow-4: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --box-shadow-inset: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  --background-color: var(--white-color);
  --color-light: var(--neutral-color050);
  --color-dark: var(--neutral-color900);
  --measure: 70ch;

  --topnav-background-color: var(--grey-color-100);
  --topnav-horizontal-padding: var(--s0);
  --topnav-color: var(--font-color);
  --topnav-height: 80px;
  --topnav-logo-height: 49px;
  --topnav-logo-image-width: 19px;
  --toggle-line-height: 3px;
  --toggle-active-translate: 4px;

  --sidenav-background-color: var(--white-color);
  --sidenav-highlight-color: var(--primary-color500);
  --sidenav-color: var(--font-color);
  --sidenav-width: 300px;
  --sidebar-layout-padding-top: var(--topnav-height);
  /* offset to enable visibility of focused sidenav items
  Chrome uses a 3px border, firefox and safari just 1px */
  --sidebar-padding-offset: 3px;

  --max-content-with-sidebar-width: calc(100vw - var(--sidenav-width));

  --welcome-screen-max-content-width: 75rem;

  --modal-background: hsla(210, 18%, 22%, 0.9); /* Charcoal */

  --modal-card-margin: 10px;

  --docs-image-block-padding: 5px;

  --framework-toggle-padding-side: 12px;
  --framework-toggle-margin-side: -8px;
  --framework-toggle-margin-top: 4px;
  --framework-toggle-border-radius: 4px;
  --framework-toggle-font-size: 0.7em;

  /*
    Workaround a CSS/postprocesser issue - you have to set the units here.
   */
  --content-side-padding: 16px;

  --api-indentation: var(--s1);

  /* padding either side of inline highlighted code */
  --inline-code-padding: 0.5ch;

  /*
    I'm using actual pixels here as a work around
    for a bug in the chart-example panel that means it won't
    handle the vertical resize correctly when the height is based
    off of our dynamic font size.
   */
  --chart-example-min-height: 250px;
  --chart-example-max-height: 350px;

  /*
    Site Search Variables
  */
  --search-result-box-background: var(--white-color);
  --search-result-box-background-active: var(--grey-color-100);
  --search-result-box-max-height: 34em;
  --search-result-box-width: 33em;
  --search-result-text-highlight: hsla(20, 96%, 90%, 0.7); /* --primary-color900 */
  --search-result-label-background: var(--grey-color-200);
}

/*
 This is the width at which the content gets too squished when a side nav bar is present.
 I don't like having a fixed pixel value but it's unavoidable with the fixed position side bar.
 Unfortunately, we can't use CSS Grid over the fixed side bar because Internet Explorer.
*/
@media (max-width: 977px) {
  :root {
    --sidenav-width: 25vw;
    --content-side-padding: 0.5rem;
  }
}

/* ── Dark mode defaults ─────────────────────────────────── */
:root {
  /* Surfaces */
  --bg: #080f1e;
  --surface: #111827;
  --surface-2: #1e293b;

  /* Borders */
  --border: #334155;

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  /* Status pills / badges */
  --status-healthy-bg: rgba(34, 197, 94, 0.1);
  --status-healthy-border: rgba(34, 197, 94, 0.25);
  --status-healthy-text: #86efac;
  --status-degraded-bg: rgba(234, 179, 8, 0.1);
  --status-degraded-border: rgba(234, 179, 8, 0.28);
  --status-degraded-text: #fde047;
  --status-critical-bg: rgba(239, 68, 68, 0.1);
  --status-critical-border: rgba(239, 68, 68, 0.28);
  --status-critical-text: #fca5a5;
  --status-unknown-bg: rgba(156, 163, 175, 0.12);
  --status-unknown-border: rgba(156, 163, 175, 0.25);
  --status-unknown-text: #9ca3af;

  /* Generic buttons */
  --btn-bg: #1e293b;
  --btn-border: #334155;
  --btn-color: #94a3b8;
  --btn-hover-bg: #334155;
  --btn-hover-color: #f1f5f9;

  /* Layout toggle buttons */
  --layout-btn-bg: #1e293b;
  --layout-btn-color: #94a3b8;
  --layout-btn-border: #334155;
  --layout-btn-hover-bg: #334155;
  --layout-btn-hover-color: #f1f5f9;
  --layout-btn-active-color: #0f172a;

  /* Incident rows */
  --incident-row-hover: #1e293b;
  --incident-row-highlight: #1c1408;

  /* Node icon chip */
  --node-icon-bg: #1e293b;
  --node-icon-border: #334155;

  /* Non-theme related styling: */
  --titlebar-h: 34px;
  --right-rail-w: 300px;

  font-family: 'Inter', system-ui, Avenir, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

/* ── Light mode overrides ─────────────────────────────────── */
[data-theme='light'] {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;

  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #9ca3af;

  --status-healthy-bg: rgba(34, 197, 94, 0.1);
  --status-healthy-border: rgba(34, 197, 94, 0.25);
  --status-healthy-text: #15803d;
  --status-degraded-bg: rgba(234, 179, 8, 0.1);
  --status-degraded-border: rgba(234, 179, 8, 0.3);
  --status-degraded-text: #a16207;
  --status-critical-bg: rgba(239, 68, 68, 0.1);
  --status-critical-border: rgba(239, 68, 68, 0.3);
  --status-critical-text: #b91c1c;
  --status-unknown-bg: rgba(156, 163, 175, 0.12);
  --status-unknown-border: rgba(156, 163, 175, 0.3);
  --status-unknown-text: #6b7280;

  --btn-bg: #ffffff;
  --btn-border: #d1d5db;
  --btn-color: #374151;
  --btn-hover-bg: #f3f4f6;
  --btn-hover-color: #111827;

  --layout-btn-bg: #ffffff;
  --layout-btn-color: #6b7280;
  --layout-btn-border: #d1d5db;
  --layout-btn-hover-bg: #f3f4f6;
  --layout-btn-hover-color: #374151;
  --layout-btn-active-color: #f1f5f9;

  --incident-row-hover: #f8fafc;
  --incident-row-highlight: #fff7ed;

  --node-icon-bg: #f1f5f9;
  --node-icon-border: #e2e8f0;
}

/* Global page layout */
body {
  margin: 0;
  padding: 0;
  min-width: 320px;
  min-height: 100vh;
  background-color: var(--bg);
  overflow: hidden;
}

/* ── Legend widget (floating over graph canvas, top-left) ───── */
#legend {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  -webkit-box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
          box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 0;
  overflow: hidden;
  pointer-events: auto;

  #legend-header {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: justify;
        -ms-flex-pack: justify;
            justify-content: space-between;
    padding: 5px 8px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    cursor: default;
    -webkit-user-select: none;
       -moz-user-select: none;
        -ms-user-select: none;
            user-select: none;
    gap: 10px;

    span {
      font-weight: 600;
      font-size: 10.5px;
      color: var(--text-secondary);
      white-space: nowrap;
    }

    #legend-toggle {
      background: none;
      border: 1px solid var(--border);
      border-radius: 4px;
      width: 16px;
      height: 16px;
      font-size: 12px;
      line-height: 1;
      cursor: pointer;
      color: var(--text-muted);
      padding: 0;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-align: center;
          -ms-flex-align: center;
              align-items: center;
      -webkit-box-pack: center;
          -ms-flex-pack: center;
              justify-content: center;
      -ms-flex-negative: 0;
          flex-shrink: 0;

      &:hover {
        background: var(--btn-hover-bg);
      }
    }
  }

  #legend-body {
    padding: 6px 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    -webkit-column-gap: 2px;
       -moz-column-gap: 2px;
            column-gap: 2px;

    &.collapsed {
      display: none;
    }
  }

  .legend-section-title {
    grid-column: 1 / -1;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 3px 0 2px;
  }

  .legend-item {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--text-secondary);
    cursor: pointer;

    padding: 2px 4px;
    -webkit-transition:
      background-color 0.2s,
      color 0.2s;
    transition:
      background-color 0.2s,
      color 0.2s;

    &:hover {
      background: var(--btn-hover-bg);
      border-radius: 2px;
      color: var(--text-primary);
      -webkit-box-shadow: 0px 0px 3px #000;
              box-shadow: 0px 0px 3px #000;
    }
  }

  .legend-count {
    margin-left: auto;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
  }

  .legend-icon {
    width: 14px;
    text-align: center;
    font-size: 11px;
    -ms-flex-negative: 0;
        flex-shrink: 0;
  }

  .legend-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    -ms-flex-negative: 0;
        flex-shrink: 0;
    border: 1.5px solid rgba(128, 128, 128, 0.2);
    margin-left: 2px;
  }

  .legend-divider {
    grid-column: 1 / -1;
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
  }
}

/* ── App shell ──────────────────────────────────────────────── */
#app-container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  width: 100vw;
  overflow: hidden;
}

#health-badge {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: 6px;

  .health-pill {
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 5px;
    padding: 2px 9px 2px 7px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    border: 1px solid transparent;
    cursor: pointer;

    &:hover {
      -webkit-box-shadow: #777 0 0 2px 2px;
              box-shadow: #777 0 0 2px 2px;
    }

    &.critical {
      background: var(--status-critical-bg);
      border-color: var(--status-critical-border);
      color: var(--status-critical-text);
    }

    &.degraded {
      background: var(--status-degraded-bg);
      border-color: var(--status-degraded-border);
      color: var(--status-degraded-text);
    }

    &.healthy {
      background: var(--status-healthy-bg);
      border-color: var(--status-healthy-border);
      color: var(--status-healthy-text);
    }
  }

  .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    -ms-flex-negative: 0;
        flex-shrink: 0;
  }

  .critical .dot {
    background: #ef4444;
    -webkit-box-shadow: 0 0 4px rgba(239, 68, 68, 0.7);
            box-shadow: 0 0 4px rgba(239, 68, 68, 0.7);
  }

  .degraded .dot {
    background: #eab308;
    -webkit-box-shadow: 0 0 4px rgba(234, 179, 8, 0.6);
            box-shadow: 0 0 4px rgba(234, 179, 8, 0.6);
  }
  &.degraded {
    background: #eab308;
    -webkit-box-shadow: 0 0 4px rgba(234, 179, 8, 0.6);
            box-shadow: 0 0 4px rgba(234, 179, 8, 0.6);
  }

  .healthy .dot {
    background: #22c55e;
    -webkit-box-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
            box-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
  }
}

@-webkit-keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── Theme toggle button ─────────────────────────────────────── */
#theme-light,
#theme-dark {
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  -webkit-transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  -ms-flex-negative: 0;
      flex-shrink: 0;

  display: none;

  padding: 3px;

  &:hover {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #475569;
  }

  svg {
    width: 14px;
    height: 14px;
  }
}

html[data-theme='light'] #theme-dark,
html[data-theme='dark'] #theme-light {
  display: unset;
}

#content-container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
  -webkit-box-flex: 1;
      -ms-flex-positive: 1;
          flex-grow: 1;
  min-height: 0;

  /* ── Panel wrappers (fills remaining height below header) ──── */
  #panels {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    min-height: 0;
    overflow: hidden;

    .panel-wrapper {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
          -ms-flex-direction: column;
              flex-direction: column;
      min-height: 0;
    }

    #panel-graph {
      -webkit-box-flex: 6;
          -ms-flex: 6;
              flex: 6;
      position: relative;
    }

    #panel-timeline {
      -webkit-box-flex: 4;
          -ms-flex: 4;
              flex: 4;
      border-top: 1px solid var(--border);

      &[data-loaded='false'] #kg {
        display: none;
      }

      &[data-loaded='true'] .loader {
        display: none;
      }
    }
  }
}

/* ── Panel title bars ───────────────────────────────────────── */
.panel-titlebar {
  -ms-flex-negative: 0;
      flex-shrink: 0;
  height: var(--titlebar-h);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
  padding: 0 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.panel-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 160px;
}

.title-buttons {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
      -ms-flex-direction: row;
          flex-direction: row;
  gap: 20px;

  button {
    height: 22px;
    padding: 0 9px;
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    color: var(--layout-btn-color);
    background: var(--layout-btn-bg);
    border: 1px solid var(--layout-btn-border);
    border-radius: 6px;
    cursor: pointer;

    path {
      fill: currentColor;
    }

    &:hover:not(.active) {
      background: var(--layout-btn-hover-bg);
      color: var(--layout-btn-hover-color);
    }

    &:active:not(.active) {
      background: var(--primary-color500);
      color: var(--layout-btn-active-color);
    }
  }
}

/* ── Layout toggle buttons ───────────────────────────────────── */
.layout-btn-group {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: 0;
  -ms-flex-negative: 0;
      flex-shrink: 0;

  .layout-btn {
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 9px;
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    color: var(--layout-btn-color);
    background: var(--layout-btn-bg);
    border: 1px solid var(--layout-btn-border);
    border-radius: 0;
    -webkit-transition:
      background 0.12s,
      color 0.12s,
      border-color 0.12s;
    transition:
      background 0.12s,
      color 0.12s,
      border-color 0.12s;
    white-space: nowrap;
    line-height: 1;

    &:first-child {
      border-radius: 5px 0 0 5px;
    }

    &:last-child {
      border-radius: 0 5px 5px 0;
      border-left: none;
    }

    &.active {
      background: var(--primary-color500);
      color: var(--layout-btn-active-color);
      z-index: 1;
    }
  }
}

/* KL and KG fill the remainder of their panel wrapper */
#kl {
  -webkit-box-flex: 1;
      -ms-flex: 1;
          flex: 1;
  width: 100%;
  min-height: 0;
}
#kg {
  -webkit-box-flex: 1;
      -ms-flex: 1;
          flex: 1;
  width: 100%;
  min-height: 0;
  background: var(--bg);
}

/* ── Node detail drawer ─────────────────────────────────────── */
#node-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  -webkit-box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
          box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  z-index: -1;
  -webkit-transform: translateX(0);
          transform: translateX(0);
  -webkit-transition: -webkit-transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transition: -webkit-transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  pointer-events: none;

  &.open {
    /* transform: translateX(calc(-1 * var(--right-rail-w))); */
    -webkit-transform: translateX(-100%);
            transform: translateX(-100%);
    pointer-events: auto;
  }

  #node-drawer-content {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    min-height: 0;
    overflow: hidden;

    /* Header strip — left border colour set inline per status */
    .drawer-header {
      -ms-flex-negative: 0;
          flex-shrink: 0;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-align: center;
          -ms-flex-align: center;
              align-items: center;
      -webkit-box-pack: justify;
          -ms-flex-pack: justify;
              justify-content: space-between;
      padding: 14px 12px 12px 14px;
      border-bottom: 1px solid var(--border);
      border-left: 3px solid transparent;
      gap: 8px;
      background: var(--surface-2);

      .drawer-header-content {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
            -ms-flex-align: center;
                align-items: center;
        gap: 10px;
        min-width: 0;

        .drawer-node-icon {
          width: 34px;
          height: 34px;
          border-radius: 8px;
          background: var(--node-icon-bg);
          border: 1px solid var(--node-icon-border);
          display: -webkit-box;
          display: -ms-flexbox;
          display: flex;
          -webkit-box-align: center;
              -ms-flex-align: center;
                  align-items: center;
          -webkit-box-pack: center;
              -ms-flex-pack: center;
                  justify-content: center;
          font-size: 15px;
          -ms-flex-negative: 0;
              flex-shrink: 0;
        }

        .drawer-node-name {
          font-size: 13.5px;
          font-weight: 700;
          color: var(--text-primary);
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }

        .drawer-node-type {
          font-size: 10.5px;
          color: var(--text-muted);
          text-transform: uppercase;
          letter-spacing: 0.06em;
          margin-top: 1px;
        }
      }

      .drawer-close {
        -ms-flex-negative: 0;
            flex-shrink: 0;
        width: 26px;
        height: 26px;
        border: 1px solid var(--btn-border);
        border-radius: 6px;
        background: var(--btn-bg);
        color: var(--btn-color);
        font-size: 11px;
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
            -ms-flex-align: center;
                align-items: center;
        -webkit-box-pack: center;
            -ms-flex-pack: center;
                justify-content: center;
        cursor: pointer;
        -webkit-transition:
          background 0.15s,
          color 0.15s;
        transition:
          background 0.15s,
          color 0.15s;

        &:hover {
          background: var(--btn-hover-bg);
          color: var(--btn-hover-color);
        }
      }
    }

    /* Scrollable body */
    .drawer-body {
      -webkit-box-flex: 1;
          -ms-flex: 1;
              flex: 1;
      overflow-y: auto;
      padding: 0;
      background: var(--surface);
    }

    .drawer-section {
      padding: 12px 14px;
    }

    .drawer-section-label {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      margin-bottom: 8px;
    }

    /* Status badge */
    .drawer-status-badge {
      display: -webkit-inline-box;
      display: -ms-inline-flexbox;
      display: inline-flex;
      -webkit-box-align: center;
          -ms-flex-align: center;
              align-items: center;
      gap: 6px;
      padding: 3px 10px 3px 8px;
      border-radius: 999px;
      font-size: 11.5px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      border: 1px solid transparent;

      .drawer-status-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        -ms-flex-negative: 0;
            flex-shrink: 0;
      }
    }

    /* Status message alert */
    .drawer-alert {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-align: start;
          -ms-flex-align: start;
              align-items: flex-start;
      gap: 8px;
      margin: 0 14px 2px;
      padding: 8px 10px;
      border-radius: 6px;
      border: 1px solid #777;
      font-size: 11.5px;
      line-height: 1.45;

      .drawer-alert-icon {
        margin-top: 1px;
        -ms-flex-negative: 0;
            flex-shrink: 0;
      }
    }

    /* Key-value metadata */
    .drawer-meta-grid {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
          -ms-flex-direction: column;
              flex-direction: column;
      gap: 5px;

      .drawer-meta-row {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: baseline;
            -ms-flex-align: baseline;
                align-items: baseline;
        -webkit-box-pack: justify;
            -ms-flex-pack: justify;
                justify-content: space-between;
        gap: 8px;

        .drawer-meta-label {
          font-size: 11px;
          color: var(--text-muted);
          white-space: nowrap;
        }

        .drawer-meta-value {
          font-size: 11.5px;
          color: var(--text-secondary);
          font-weight: 500;
          text-align: right;
          word-break: break-word;
        }
      }
    }

    /* Description */
    .drawer-description {
      margin: 0;
      font-size: 12px;
      color: var(--text-secondary);
      line-height: 1.55;
    }

    .drawer-divider {
      border: none;
      border-top: 1px solid var(--border);
      margin: 0;
    }

    /* Live metrics 2×2 grid */
    .drawer-metrics-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;

      .drawer-metric-card {
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px 10px 8px;
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
            -ms-flex-direction: column;
                flex-direction: column;
        gap: 3px;

        .drawer-metric-value {
          font-size: 17px;
          font-weight: 700;
          color: var(--text-primary);
          letter-spacing: -0.02em;
          line-height: 1;
        }

        .drawer-metric-label {
          font-size: 10px;
          color: var(--text-muted);
          text-transform: uppercase;
          letter-spacing: 0.06em;
          font-weight: 500;
        }
      }
    }

    &[data-status='healthy'] {
      .drawer-status-badge {
        background: var(--status-healthy-bg);
        border-color: var(--status-healthy-border);
        color: var(--status-healthy-text);
      }

      .drawer-status-dot {
        background: #22c55e;
        -webkit-box-shadow: 0 0 4px rgba(34, 197, 94, 0.6);
                box-shadow: 0 0 4px rgba(34, 197, 94, 0.6);
      }

      .drawer-metric-card .drawer-metric-value {
        color: var(--status-healthy-text);
      }
    }

    &[data-status='degraded'] {
      .drawer-status-badge {
        background: var(--status-degraded-bg);
        border-color: var(--status-degraded-border);
        color: var(--status-degraded-text);
      }

      .drawer-status-dot {
        background: #eab308;
        -webkit-box-shadow: 0 0 4px rgba(234, 179, 8, 0.6);
                box-shadow: 0 0 4px rgba(234, 179, 8, 0.6);
      }

      .drawer-alert {
        background: var(--status-degraded-bg);
        border-color: var(--status-degraded-border);
        color: var(--status-degraded-text);
      }

      .drawer-metric-card .drawer-metric-value {
        color: var(--status-degraded-text);
      }
    }

    &[data-status='critical'] {
      .drawer-status-badge {
        background: var(--status-critical-bg);
        border-color: var(--status-critical-border);
        color: var(--status-critical-text);
      }

      .drawer-status-dot {
        background: #ef4444;
        -webkit-box-shadow: 0 0 4px rgba(239, 68, 68, 0.7);
                box-shadow: 0 0 4px rgba(239, 68, 68, 0.7);
        -webkit-animation: pulse-dot 1.4s ease-in-out infinite;
                animation: pulse-dot 1.4s ease-in-out infinite;
      }

      .drawer-alert {
        background: var(--status-critical-bg);
        border-color: var(--status-critical-border);
        color: var(--status-critical-text);
      }

      .drawer-metric-card .drawer-metric-value {
        color: var(--status-critical-text);
      }
    }

    &[data-status='unknown'] {
      .drawer-status-badge {
        background: var(--status-unknown-bg);
        border-color: var(--status-unknown-border);
        color: var(--status-unknown-text);
      }

      .drawer-metric-value {
        color: var(--status-unknown-text);
      }
    }
  }
}

/* ── Incident sidebar ───────────────────────────────────────── */
#incident-sidebar {
  width: var(--right-rail-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  -webkit-box-shadow: -4px 0 20px rgba(0, 0, 0, 0.25);
          box-shadow: -4px 0 20px rgba(0, 0, 0, 0.25);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  z-index: 230;
  -webkit-transform: translateX(0);
          transform: translateX(0);
  -webkit-transition: -webkit-transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transition: -webkit-transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;

  #incident-sidebar-header {
    -ms-flex-negative: 0;
        flex-shrink: 0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: justify;
        -ms-flex-pack: justify;
            justify-content: space-between;
    padding: 10px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    gap: 8px;
  }

  #incident-list {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    overflow-y: auto;
    min-height: 140px;
    background: var(--surface);
  }

  .incident-row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: start;
        -ms-flex-align: start;
            align-items: flex-start;
    -webkit-box-pack: justify;
        -ms-flex-pack: justify;
            justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    cursor: pointer;
    -webkit-transition: background 0.12s;
    transition: background 0.12s;
    -webkit-animation: alert-slide-in 0.25s ease-out;
            animation: alert-slide-in 0.25s ease-out;

    &:hover {
      background: var(--incident-row-hover);
    }

    &.highlight {
      background: var(--incident-row-highlight);
    }

    .incident-row-left {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-align: start;
          -ms-flex-align: start;
              align-items: flex-start;
      gap: 8px;
      min-width: 0;

      .incident-severity {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        -ms-flex-negative: 0;
            flex-shrink: 0;
        margin-top: 4px;

        &.critical {
          background: #ef4444;
          -webkit-box-shadow: 0 0 4px rgba(239, 68, 68, 0.7);
                  box-shadow: 0 0 4px rgba(239, 68, 68, 0.7);
          -webkit-animation: pulse-dot 1.4s ease-in-out infinite;
                  animation: pulse-dot 1.4s ease-in-out infinite;
        }

        &.degraded {
          background: #eab308;
          -webkit-box-shadow: 0 0 3px rgba(234, 179, 8, 0.5);
                  box-shadow: 0 0 3px rgba(234, 179, 8, 0.5);
        }
      }

      .incident-row-content {
        min-width: 0;

        .incident-row-name {
          font-size: 12px;
          font-weight: 700;
          color: var(--text-primary);
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;

          i {
            font-size: 9px;
            margin-right: 4px;
            opacity: 0.6;
          }
        }

        .incident-row-msg {
          font-size: 11px;
          color: var(--text-muted);
          line-height: 1.4;
          margin-top: 2px;
          display: -webkit-box;
          line-clamp: 2;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
        }
      }
    }

    .incident-row-right {
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
          -ms-flex-direction: column;
              flex-direction: column;
      -webkit-box-align: end;
          -ms-flex-align: end;
              align-items: flex-end;
      gap: 6px;
      -ms-flex-negative: 0;
          flex-shrink: 0;

      .incident-row-time {
        font-size: 9.5px;
        color: var(--text-muted);
        white-space: nowrap;
      }

      .incident-resolve-btn {
        display: -webkit-inline-box;
        display: -ms-inline-flexbox;
        display: inline-flex;
        -webkit-box-align: center;
            -ms-flex-align: center;
                align-items: center;
        -webkit-box-pack: center;
            -ms-flex-pack: center;
                justify-content: center;
        width: 20px;
        height: 20px;
        border: 1px solid var(--btn-border);
        border-radius: 4px;
        background: var(--btn-bg);
        color: #22c55e;
        font-size: 9px;
        cursor: pointer;
        -webkit-transition:
          background 0.12s,
          border-color 0.12s;
        transition:
          background 0.12s,
          border-color 0.12s;

        &:hover {
          background: rgba(34, 197, 94, 0.1);
          border-color: rgba(34, 197, 94, 0.4);
        }
      }
    }
  }
}

@-webkit-keyframes alert-slide-in {
  from {
    opacity: 0;
    -webkit-transform: translateX(12px);
            transform: translateX(12px);
  }
  to {
    opacity: 1;
    -webkit-transform: translateX(0);
            transform: translateX(0);
  }
}

@keyframes alert-slide-in {
  from {
    opacity: 0;
    -webkit-transform: translateX(12px);
            transform: translateX(12px);
  }
  to {
    opacity: 1;
    -webkit-transform: translateX(0);
            transform: translateX(0);
  }
}

.loader {
  width: 48px;
  height: 48px;
  border: 5px solid #fff;
  border-bottom-color: transparent;
  border-radius: 50%;
  display: inline-block;
  -webkit-animation: rotation 1s linear infinite;
          animation: rotation 1s linear infinite;
  margin: auto;
}

@-webkit-keyframes rotation {
  0% {
    -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}

@keyframes rotation {
  0% {
    -webkit-transform: rotate(0deg);
            transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}

