@import '../../styles/variables.css';

/* ── 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);
  }
}
