/* ── Dark theme (default) ────────────────────────────────────────── */
:root {
  --bg:        #0d0f18;
  --surface:   #13161f;
  --surface2:  #1c1f2e;
  --border:    #252837;
  --text:      #e2e5f0;
  --muted:     #5a6380;
  --green:     #22c55e;
  --red:       #f04343;
  --orange:    #f59e0b;
  --blue:      #3b82f6;
  --purple:    #8b5cf6;
  --gray:      #374151;
  --shadow:    rgba(0,0,0,0.35);
  --shadow-lg: rgba(0,0,0,0.5);
  --brand:     #4e7fd5;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

/* ── Light theme ─────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f0f2f8;
  --surface:   #ffffff;
  --surface2:  #e8ebf5;
  --border:    #d8dcea;
  --text:      #13162a;
  --muted:     #6b748e;
  --green:     #16a34a;
  --red:       #dc2626;
  --orange:    #d97706;
  --blue:      #2563eb;
  --purple:    #7c3aed;
  --gray:      #94a3b8;
  --shadow:    rgba(0,0,0,0.08);
  --shadow-lg: rgba(0,0,0,0.15);
  --brand:     #0d1f3c;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

/* ── Header ──────────────────────────────────────────────────────── */
header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.header-left  { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.header-center { flex: 1; display: flex; align-items: center; gap: 1rem; overflow: hidden; }
.header-right  { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

.logo { color: var(--brand); font-size: 1.2rem; }
h1   { font-size: 0.9rem; font-weight: 700; letter-spacing: -0.01em; }

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.67rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}
.env-pill .label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.env-pill .up    { color: var(--green); font-weight: 700; }
.env-pill .down  { color: var(--red);   font-weight: 700; }
.env-pill .deg   { color: var(--orange);font-weight: 700; }

.badge-neutral { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 26px; height: 26px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn.paused { color: var(--orange); border-color: var(--orange); }

/* ── Notification bell ───────────────────────────────────────────── */
.notif-wrapper { position: relative; }
.notif-btn { font-size: 1rem; }

.notif-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--red);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.52rem;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}
.notif-badge.hidden { display: none; }

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px var(--shadow-lg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notif-dropdown.hidden { display: none; }

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
}

#notif-list { overflow-y: auto; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { border-left: 2px solid var(--blue); }

.notif-dot     { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.notif-content { flex: 1; min-width: 0; }
.notif-svc     { font-size: 0.72rem; font-weight: 600; color: var(--text); margin-bottom: 0.15rem; }
.notif-msg     { font-size: 0.7rem; color: var(--muted); line-height: 1.35; margin-bottom: 0.2rem; }
.notif-meta    { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); }
.notif-arrow   { font-size: 0.7rem; color: var(--muted); flex-shrink: 0; margin-top: 2px; }
.notif-empty   { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: 0.75rem; }

/* ── Layout ──────────────────────────────────────────────────────── */
.body-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar overlay (mobile drawer backdrop) ────────────────────── */
.sidebar-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.sidebar-overlay.visible { display: block; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.75rem 0 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-section { margin-bottom: 1.1rem; }

.sidebar-section-title {
  font-size: 0.57rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 0 1rem;
  margin-bottom: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  border-left: 2px solid transparent;
  transition: color 0.1s, background 0.1s;
  user-select: none;
}
.nav-item:hover  { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--text); border-left-color: var(--green); background: var(--surface2); }
.nav-item.active-incidents { border-left-color: var(--orange); }

.nav-badge {
  font-family: var(--mono);
  font-size: 0.6rem;
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  min-width: 1.3rem;
  text-align: center;
}
.nav-badge.danger   { background: rgba(240,67,67,0.15);  color: var(--red);    font-weight: 700; }
.nav-badge.warn     { background: rgba(245,158,11,0.15); color: var(--orange); font-weight: 700; }
.nav-badge.incident { background: rgba(245,158,11,0.15); color: var(--orange); font-weight: 700; }

/* Sidebar logs */
.sidebar-logs {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  margin-bottom: 0;
}
.log-list { flex: 1; overflow-y: auto; }
.log-entry { display: flex; align-items: center; gap: 0.3rem; padding: 0.25rem 1rem; }
.log-entry.log-down { background: rgba(240,67,67,0.04); }
.log-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.log-dot.up   { background: var(--green); }
.log-dot.down { background: var(--red); }
.log-name { flex: 1; min-width: 0; font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.log-env-tag { font-family: var(--mono); font-size: 0.54rem; color: var(--muted); background: var(--bg); border: 1px solid var(--border); padding: 0.04rem 0.22rem; border-radius: 3px; flex-shrink: 0; }
.log-time { font-family: var(--mono); font-size: 0.58rem; color: var(--muted); flex-shrink: 0; width: 1.8rem; text-align: right; }
.log-empty { padding: 0.4rem 1rem; font-size: 0.7rem; color: var(--muted); }

/* ── Main content ────────────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 1.1rem; }
.hidden  { display: none !important; }

.section-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}
.section-header h2   { font-size: 0.9rem; font-weight: 600; }
.section-header .section-sub { font-size: 0.72rem; color: var(--muted); }

.empty-state { text-align: center; color: var(--muted); font-size: 0.875rem; padding: 3rem 2rem; }

/* ── Service grid ────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 0.75rem;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover    { border-color: var(--border); box-shadow: 0 4px 16px var(--shadow); }
.card.has-down     { border-color: rgba(240,67,67,0.22); }
.card.has-degraded { border-color: rgba(245,158,11,0.25); }
.card.selected     { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.card.unconfigured { opacity: 0.55; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
  gap: 0.4rem;
}
.card-name { font-size: 0.85rem; font-weight: 600; }

.card-badges { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; }

/* Generic badge */
.badge {
  font-family: var(--mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-type      { color: var(--muted); background: var(--surface2); border-color: var(--border); }
.badge-critical  { color: var(--red);    background: rgba(240,67,67,0.1);  border-color: rgba(240,67,67,0.2); }
.badge-high      { color: var(--orange); background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.2); }
.badge-medium    { color: #a3a3a3;       background: var(--surface2);      border-color: var(--border); }
.badge-low       { color: var(--muted);  background: var(--bg);            border-color: var(--border); }

/* Env rows in card */
.env-block     { margin-bottom: 0.45rem; }
.env-block:last-child { margin-bottom: 0; }

.env-row { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.25rem; }
.env-label {
  font-family: var(--mono);
  font-size: 0.56rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  width: 2.4rem;
  flex-shrink: 0;
}

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot.up           { background: var(--green);  box-shadow: 0 0 4px var(--green); }
.dot.down         { background: var(--red);    box-shadow: 0 0 4px var(--red); }
.dot.degraded     { background: var(--orange); box-shadow: 0 0 4px var(--orange); }
.dot.checking     { background: var(--gray);   animation: pulse 1.5s infinite; }
.dot.unconfigured { background: var(--gray);   opacity: 0.4; }
.dot.unknown      { background: var(--gray);   opacity: 0.6; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }

.rt-inline { font-family: var(--mono); font-size: 0.8rem; font-weight: 600; min-width: 3rem; }
.rt-inline .unit { font-size: 0.6rem; font-weight: 400; color: var(--muted); margin-left: 1px; }

.status-label { font-family: var(--mono); font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.status-label.up           { color: var(--green); }
.status-label.down         { color: var(--red); }
.status-label.degraded     { color: var(--orange); }
.status-label.checking     { color: var(--muted); }
.status-label.unconfigured { color: var(--muted); opacity: 0.5; }
.status-label.unknown      { color: var(--muted); }

.spacer { flex: 1; }
.last-checked { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); white-space: nowrap; }

.history { display: flex; gap: 2px; height: 11px; align-items: flex-end; }
.hbar { flex: 1; border-radius: 2px; min-width: 0; }
.hbar.up       { background: var(--green);  opacity: 0.55; height: 100%; }
.hbar.down     { background: var(--red);    opacity: 0.6;  height: 100%; }
.hbar.degraded { background: var(--orange); opacity: 0.6;  height: 100%; }
.hbar.empty    { background: var(--surface2); height: 50%; }

.env-separator { height: 1px; background: var(--border); margin: 0.45rem 0; }

.degraded-note {
  font-size: 0.63rem;
  color: var(--orange);
  font-family: var(--mono);
  margin-top: 0.25rem;
  padding: 0.2rem 0.4rem;
  background: rgba(245,158,11,0.06);
  border-radius: 4px;
  border-left: 2px solid var(--orange);
}

/* ── Queue grid ──────────────────────────────────────────────────── */
.queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.queue-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.queue-card.q-down     { border-color: rgba(240,67,67,0.22); }
.queue-card.q-degraded { border-color: rgba(245,158,11,0.22); }

.queue-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.queue-name { font-size: 0.82rem; font-weight: 600; }

.queue-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 0.5rem; }
.qm { display: flex; flex-direction: column; }
.qm-label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.qm-value { font-family: var(--mono); font-size: 0.82rem; font-weight: 600; }
.qm-value.warn { color: var(--orange); }
.qm-value.crit { color: var(--red); }

/* ── Business health ─────────────────────────────────────────────── */
.biz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}

.biz-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.875rem;
}
.biz-metric-label { font-size: 0.63rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.25rem; }
.biz-metric-value { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; line-height: 1; }
.biz-metric-value.warn { color: var(--orange); }
.biz-metric-value.crit { color: var(--red); }
.biz-metric-value.ok   { color: var(--green); }

.mock-badge { font-family: var(--mono); font-size: 0.6rem; color: var(--orange); border: 1px solid rgba(245,158,11,0.3); padding: 0.1rem 0.4rem; border-radius: 4px; }

/* ── Incident / alert cards ──────────────────────────────────────── */
.incident-card, .alert-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.incident-card.sev-critical { border-left: 3px solid var(--red); }
.incident-card.sev-high     { border-left: 3px solid var(--orange); }
.incident-card.sev-medium   { border-left: 3px solid var(--blue); }

.inc-body { flex: 1; min-width: 0; }
.inc-title { font-size: 0.82rem; font-weight: 600; margin-bottom: 0.2rem; }
.inc-meta  { font-size: 0.67rem; color: var(--muted); font-family: var(--mono); }
.inc-status { font-family: var(--mono); font-size: 0.6rem; font-weight: 700; text-transform: uppercase; padding: 0.12rem 0.35rem; border-radius: 4px; }
.inc-status.open         { color: var(--red);    background: rgba(240,67,67,0.1); }
.inc-status.acknowledged { color: var(--orange); background: rgba(245,158,11,0.1); }
.inc-status.resolved     { color: var(--green);  background: rgba(34,197,94,0.1); }
.inc-status.up           { color: var(--green);  background: rgba(34,197,94,0.1); }
.inc-status.down         { color: var(--red);    background: rgba(240,67,67,0.1); }
.inc-status.degraded     { color: var(--orange); background: rgba(245,158,11,0.1); }
.inc-status.unknown      { color: var(--muted);  background: var(--surface2); }

/* Custom domains */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}
.domain-issues {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.domain-issues.wide {
  background: rgba(245,158,11,0.06);
  border: 1px solid rgba(245,158,11,0.18);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
}
.domain-table {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.domain-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(100px, 1fr) auto minmax(70px, auto);
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
}
.domain-row:last-child { border-bottom: none; }
.domain-host,
.domain-tenant,
.domain-time {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.domain-host {
  font-family: var(--mono);
  color: var(--text);
}
.domain-tenant,
.domain-time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
}
.empty-state.compact {
  padding: 0.65rem 0;
  text-align: left;
  font-size: 0.72rem;
}

@media (max-width: 760px) {
  .domain-row {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 0.25rem;
  }
}

/* ── Mobile layout ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Header: compact */
  header { padding: 0.45rem 0.75rem; gap: 0.5rem; }
  .header-center { display: none; }
  .badge-neutral  { display: none; }

  /* Body area: reference point for absolute children */
  .body-area { position: relative; }

  /* Sidebar: overlay drawer — switch from width-collapse to transform */
  .sidebar {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    width: 220px;
    transform: translateX(0);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.75rem 0 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
  }
  /* Collapsed = off-screen left; reset the desktop width:0 */
  .sidebar.collapsed {
    width: 220px;
    padding: 0.75rem 0 0;
    overflow: hidden;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
  }

  /* Content: full width (sidebar is now out of flow) */
  .content { padding: 0.75rem; }

  /* Section header */
  .section-header { padding-bottom: 0.6rem; }

  /* Service cards: single column on small screens */
  .grid { grid-template-columns: 1fr !important; }

  /* Domain grid: single column */
  .domain-grid { grid-template-columns: 1fr; }

  /* Queue grid: 1–2 col */
  .queue-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  /* Biz grid: 2 col */
  .biz-grid { grid-template-columns: repeat(2, 1fr); }

  /* Detail panel: full-screen overlay */
  .detail-panel.open {
    position: absolute;
    inset: 0;
    width: 100%;
    z-index: 45;
    overflow-y: auto;
    border-left: none;
    transition: none;
  }
  .detail-inner { width: 100%; }

  /* Modal: full width */
  .modal, .modal-wide { max-width: 100%; border-radius: 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 12px 12px 0 0; max-height: 85vh; }

  /* List rows: hide env detail, keep essentials */
  .list-envs { display: none; }
  .list-time  { display: none; }
}

@media (max-width: 420px) {
  h1 { display: none; }
  .logo { font-size: 1rem; }
}

.ack-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.1s;
  flex-shrink: 0;
}
.ack-btn:hover { color: var(--text); border-color: var(--muted); }

/* Incidents strip (below service grid) */
.incidents-strip {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.875rem;
}
.incidents-strip-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--orange);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

/* ── Logs modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.hidden { display: none !important; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 0.82rem; font-weight: 700; }
.modal-header-actions { display: flex; align-items: center; gap: 0.6rem; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}

.modal-log-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.73rem;
  border-bottom: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.2rem;
}
.modal-log-row:last-child { border-bottom: none; }
.modal-log-row .log-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

/* ── Domain list modal ───────────────────────────────────────────── */
.modal-wide { max-width: 720px; }

.filter-pills { display: flex; gap: 0.35rem; }
.filter-pill {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s;
}
.filter-pill.active,
.filter-pill:hover { border-color: var(--brand); color: var(--text); }

.modal-domain-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(100px, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.73rem;
}
.modal-domain-row:last-child { border-bottom: none; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Detail panel ────────────────────────────────────────────────── */
.detail-panel {
  flex-shrink: 0;
  width: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: none;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.detail-panel.open { width: 370px; overflow-y: auto; border-left: 1px solid var(--border); }

.detail-inner { width: 370px; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.1rem 0.875rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.detail-name   { font-size: 1rem; font-weight: 700; margin-bottom: 0.35rem; }
.detail-badges { display: flex; gap: 0.3rem; flex-wrap: wrap; }

/* Detail panel tabs */
.detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 72px; /* below detail-header */
  z-index: 1;
}
.detail-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.55rem 0;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
  letter-spacing: 0.02em;
}
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--text); border-bottom-color: var(--green); }

/* Diagnose tab */
.diagnose-body { padding: 1rem 1.1rem; }

.diagnose-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}

.diagnose-cause {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.875rem;
}
.diagnose-cause-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.diagnose-cause-text {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.45;
}
.diagnose-cause.is-ok   { border-color: rgba(34,197,94,0.3);  background: rgba(34,197,94,0.05); }
.diagnose-cause.is-warn { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.05); }
.diagnose-cause.is-crit { border-color: rgba(240,67,67,0.3);  background: rgba(240,67,67,0.05); }

.diagnose-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}
.diagnose-step {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.45;
}
.step-num {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-top: 1px;
}
.step-text { color: var(--text); }
.step-text code {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.diagnose-run-btn {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.55rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.1s;
  margin-bottom: 0.875rem;
  font-family: var(--mono);
}
.diagnose-run-btn:hover    { border-color: var(--green); color: var(--green); }
.diagnose-run-btn:disabled { opacity: 0.5; cursor: wait; }
.diagnose-run-btn.running  { color: var(--orange); border-color: var(--orange); }

/* Kimi-specific styles */
.kimi-btn   { border-color: rgba(139,92,246,0.4); color: var(--purple); }
.kimi-btn:hover { border-color: var(--purple); background: rgba(139,92,246,0.05); }
.kimi-hint  { font-size: 0.65rem; color: var(--muted); margin-bottom: 0.75rem; padding: 0 0.1rem; }
.kimi-icon  { display: inline-block; }
.kimi-spin  { animation: kimi-pulse 1.2s ease-in-out infinite; }
@keyframes kimi-pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.kimi-response {
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 8px;
  background: rgba(139,92,246,0.04);
  overflow-y: auto;
  max-height: 420px;
}
.kimi-badge {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--purple);
  padding: 0.4rem 0.75rem 0;
  opacity: 0.8;
}
.kimi-body {
  padding: 0.5rem 0.75rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text);
}
.kimi-cursor { opacity: 0.6; animation: kimi-blink 0.8s step-end infinite; }
@keyframes kimi-blink { 0%,100%{opacity:0.6} 50%{opacity:0} }

.kimi-error {
  padding: 0.65rem 0.75rem;
  font-size: 0.72rem;
  color: var(--red);
}

/* Markdown inside kimi-body */
.md-h3  { font-size: 0.82rem; font-weight: 700; margin: 0.75rem 0 0.3rem; color: var(--text); }
.md-h4  { font-size: 0.77rem; font-weight: 700; margin: 0.6rem 0 0.25rem; color: var(--text); }
.md-li  { display: flex; gap: 0.4rem; margin: 0.2rem 0; align-items: flex-start; }
.md-num { font-family: var(--mono); font-size: 0.65rem; font-weight: 700; color: var(--purple); flex-shrink: 0; min-width: 1rem; }
.md-bullet { color: var(--muted); flex-shrink: 0; }
.inline-code {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.08rem 0.3rem;
  border-radius: 3px;
  color: var(--text);
}

.env-select-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.1s;
}
.env-select-btn:hover  { color: var(--text); border-color: var(--muted); }
.env-select-btn.active { color: var(--text); background: var(--surface2); border-color: var(--muted); }

.close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: all 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.close-btn:hover { color: var(--text); border-color: var(--muted); }

.detail-body { padding: 1rem 1.1rem; }

.detail-env { margin-bottom: 1rem; }
.detail-env + .detail-env { padding-top: 1rem; border-top: 1px solid var(--border); }

.detail-env-title { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.55rem; }
.detail-env-badge { font-family: var(--mono); font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.detail-rt { font-family: var(--mono); font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; margin-bottom: 0.55rem; }
.detail-rt .unit { font-size: 0.75rem; font-weight: 400; color: var(--muted); margin-left: 2px; }

.detail-url { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); word-break: break-all; padding: 0.35rem 0.55rem; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; margin-bottom: 0.65rem; }

.error-block { background: rgba(240,67,67,0.07); border: 1px solid rgba(240,67,67,0.2); border-radius: 7px; padding: 0.6rem 0.7rem; margin-bottom: 0.75rem; }
.error-reason { display: flex; align-items: flex-start; gap: 0.3rem; font-size: 0.75rem; color: #fca5a5; margin-bottom: 0.5rem; line-height: 1.4; }
.error-reason:last-child { margin-bottom: 0; }
.fix-label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.25rem; }
.fix-cmd   { display: flex; align-items: center; gap: 0.4rem; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 0.3rem 0.45rem; }
.fix-code  { font-family: var(--mono); font-size: 0.7rem; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn  { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); font-family: var(--mono); font-size: 0.58rem; padding: 0.18rem 0.45rem; border-radius: 4px; cursor: pointer; flex-shrink: 0; transition: all 0.1s; }
.copy-btn:hover  { color: var(--text); border-color: var(--muted); }
.copy-btn.copied { color: var(--green); border-color: rgba(34,197,94,0.4); }

.detail-meta { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
.detail-meta-item { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.55rem; }
.detail-meta-label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.18rem; }
.detail-meta-value { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; }

.section-label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.3rem; }

.history-large { display: flex; gap: 2px; height: 32px; align-items: flex-end; margin-bottom: 0.875rem; }
.history-large .hbar { flex: 1; min-width: 0; border-radius: 2px; }

.sparkline { display: flex; gap: 2px; height: 32px; align-items: flex-end; margin-bottom: 0.875rem; }
.spark-bar { flex: 1; min-width: 0; border-radius: 2px; }
.spark-bar.up   { background: var(--blue); opacity: 0.7; }
.spark-bar.down { background: var(--border); }

/* Version block in detail */
.version-block { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem 0.65rem; margin-bottom: 0.75rem; }
.version-row   { display: flex; justify-content: space-between; font-size: 0.67rem; margin-bottom: 0.15rem; }
.version-row:last-child { margin-bottom: 0; }
.version-key   { color: var(--muted); }
.version-val   { font-family: var(--mono); color: var(--text); }

/* Action links */
.action-links { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.875rem; }
.action-link {
  font-family: var(--mono);
  font-size: 0.63rem;
  padding: 0.25rem 0.55rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.action-link:hover           { color: var(--text); border-color: var(--muted); }
.action-link.disabled        { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.action-link.action-restart         { border-color: rgba(240,67,67,0.35); color: var(--red); cursor: pointer; }
.action-link.action-restart:hover   { background: rgba(240,67,67,0.08); }
.action-link.action-restart:disabled{ opacity: 0.5; cursor: wait; }

.restart-confirm {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(245,158,11,0.07);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 6px;
  font-size: 0.75rem;
}
.restart-confirm-msg { flex: 1; color: var(--text); }
.restart-confirm-btn {
  padding: 0.25rem 0.7rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface2);
  color: var(--text);
  transition: all 0.1s;
}
.restart-confirm-btn.yes { background: var(--red); border-color: var(--red); color: #fff; }
.restart-confirm-btn.yes:hover { opacity: 0.85; }
.restart-confirm-btn.no:hover  { background: var(--surface); }

.restart-result {
  margin: 0.5rem 0 0.875rem;
  border-radius: 7px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
}
.restart-result.ok   { border-color: rgba(34,197,94,0.3);  background: rgba(34,197,94,0.05); }
.restart-result.warn { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.05); }
.restart-result.err  { border-color: rgba(240,67,67,0.3);  background: rgba(240,67,67,0.05); }

.restart-result-title { font-size: 0.75rem; font-weight: 700; margin-bottom: 0.3rem; }
.restart-result.ok   .restart-result-title { color: var(--green); }
.restart-result.warn .restart-result-title { color: var(--orange); }
.restart-result.err  .restart-result-title { color: var(--red); }

.restart-output {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 0.4rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
}

/* Dependencies in detail */
.dep-list     { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.875rem; }
.dep-row      { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.75rem; }
.dep-row-left { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.dep-name     { color: var(--text); white-space: nowrap; }
.dep-rt       { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); }
.dep-bars     { display: flex; gap: 1px; height: 10px; align-items: flex-end; flex: 1; min-width: 0; max-width: 110px; }
.dep-bars .hbar { flex: 1; min-width: 0; border-radius: 1px; }

/* ── Dev-only badge ──────────────────────────────────────────────── */
.badge-devonly { color: var(--purple); background: rgba(139,92,246,0.1); border-color: rgba(139,92,246,0.25); }

/* ── Biz health mini-strip ───────────────────────────────────────── */
.biz-strip { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-size: 0.72rem; color: var(--muted); }
.biz-strip-item        { white-space: nowrap; }
.biz-strip-item strong { color: var(--text); font-weight: 600; font-family: var(--mono); }
.biz-strip-item.warn   { color: var(--orange); font-weight: 600; }
.biz-strip-item.crit   { color: var(--red);    font-weight: 600; }
.biz-strip-sep         { color: var(--border); }

/* ── Incident workflows + audit ──────────────────────────────────── */
.inc-workflows { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.4rem; }
.inc-audit     { margin-top: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.4rem; display: flex; flex-direction: column; gap: 0.2rem; }
.audit-row     { display: flex; align-items: center; gap: 0.4rem; font-size: 0.65rem; font-family: var(--mono); }
.audit-ts      { color: var(--muted); min-width: 4rem; }
.audit-action  { color: var(--text); font-weight: 600; text-transform: uppercase; font-size: 0.58rem; letter-spacing: 0.06em; }
.audit-by      { color: var(--muted); }

/* ── View toggle ─────────────────────────────────────────────────── */
.view-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.view-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
}
.view-btn:hover  { color: var(--text); border-color: var(--muted); }
.view-btn.active { color: var(--text); background: var(--surface2); border-color: var(--muted); }

/* ── List view ───────────────────────────────────────────────────── */
.list-view { display: flex; flex-direction: column; gap: 2px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  min-width: 0;
}
.list-row:hover          { background: var(--surface2); }
.list-row.selected       { border-color: var(--blue); }
.list-row.has-down       { border-left: 3px solid var(--red); }
.list-row.has-degraded   { border-left: 3px solid var(--orange); }

.list-name  { font-size: 0.82rem; font-weight: 600; white-space: nowrap; min-width: 130px; flex-shrink: 0; }
.list-badges{ display: flex; gap: 0.25rem; flex-shrink: 0; }
.list-envs  { display: flex; gap: 0.625rem; flex: 1; justify-content: flex-end; }

.list-env-cell {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 110px;
  font-family: var(--mono);
  font-size: 0.7rem;
}
.list-env-label { font-size: 0.56rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; width: 2.1rem; flex-shrink: 0; }
.list-env-rt    { font-weight: 600; min-width: 2.8rem; }
.list-env-na    { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); opacity: 0.5; min-width: 110px; }
.list-time      { font-family: var(--mono); font-size: 0.6rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; min-width: 55px; text-align: right; }

/* Service logs in detail panel */
.svc-log-list { display: flex; flex-direction: column; gap: 1px; }
.svc-log-row  { display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.svc-log-row:last-child { border-bottom: none; }
.svc-log-rt   { font-family: var(--mono); font-size: 0.67rem; color: var(--text); min-width: 2.8rem; }

/* Workflow tags */
.workflow-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.875rem; }
.workflow-tag  { font-family: var(--mono); font-size: 0.6rem; padding: 0.12rem 0.35rem; border-radius: 4px; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); }

/* ── Python Observability panels ─────────────────────────────────── */
.config-group       { margin-bottom: 1rem; }
.config-group-title { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.35rem; }
.config-group-title.danger { color: var(--red); }
.config-group-title.warn   { color: var(--orange); }
.config-group-title.ok     { color: var(--green); }

.config-row        { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 0.72rem; }
.config-row:last-child { border-bottom: none; }
.config-name       { flex: 1; color: var(--text); }
.config-cat        { color: var(--muted); font-size: 0.6rem; }

.badge-missing        { background: rgba(240,67,67,0.15); color: var(--red); border-color: rgba(240,67,67,0.3); }
.badge-optional_missing { background: rgba(245,158,11,0.1); color: var(--orange); border-color: rgba(245,158,11,0.25); }

.audit-list        { display: flex; flex-direction: column; gap: 1px; }
.audit-row         { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 0.7rem; }
.audit-row:last-child { border-bottom: none; }
.audit-ts          { color: var(--muted); min-width: 5rem; flex-shrink: 0; }
.audit-action      { color: var(--blue); min-width: 8rem; }
.audit-actor       { color: var(--text); min-width: 7rem; }
.audit-svc         { color: var(--muted); }
.audit-reason      { color: var(--muted); font-style: italic; }

.py-ack-btn        { margin-top: 0.35rem; font-size: 0.65rem; padding: 0.2rem 0.5rem; cursor: pointer; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 3px; }
.py-ack-btn:hover  { border-color: var(--blue); color: var(--blue); }

.inc-workflows     { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.3rem 0; }
.wf-tag            { font-family: var(--mono); font-size: 0.6rem; padding: 0.1rem 0.3rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; color: var(--muted); }
