/* Zimac Metrics — dark dashboard.
 * Design tokens and the visual language are lifted from the Axon desktop app
 * (apps/desktop/public/style.css) so this internal tool feels native to the
 * family: same charcoal surfaces, same #6c63ff accent, same system type, the
 * same constellation-glow ambience and sage→indigo gradient headers — tuned
 * down to read as a calm metrics site rather than a chat surface. */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #232733;
  --border: #2a2e3a;
  --text: #e4e4e7;
  --text-muted: #8b8d98;
  --accent: #6c63ff;
  --accent-dim: #4f46e5;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;

  /* The Axon "agent" palette — the family's series colours, reused verbatim so
   * a chart here is tinted the same as a chart in the app.
   *   sage  #f472b6  ·  kai   #60a5fa  ·  joy   #c084fc
   *   cody  #2dd4bf  ·  green #34d399  ·  amber #fbbf24 */
  --sage: #f472b6;
  --c-kai: #60a5fa;
  --c-joy: #c084fc;
  --c-cody: #2dd4bf;

  /* Chart series cycle (consumed by app.js). */
  --c1: #6c63ff;
  --c2: #34d399;
  --c3: #60a5fa;
  --c4: #fbbf24;
  --c5: #f472b6;
  --c6: #2dd4bf;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ----- Sidebar ----- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 22px;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 6px 16px -5px rgba(108, 99, 255, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  /* The app's sage→indigo wordmark, applied to our name. */
  background: linear-gradient(90deg, var(--sage), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub {
  color: var(--text-muted);
  font-size: 12px;
}

.side-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.side-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.select,
.input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: 13px var(--font);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.select:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.16);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  position: relative;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 9px 11px;
  border-radius: 8px;
  font: 13px var(--font);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.nav-item.active {
  background: rgba(108, 99, 255, 0.14);
  color: var(--text);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(var(--sage), var(--accent));
  box-shadow: 0 0 8px rgba(108, 99, 255, 0.6);
}

.side-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.dot.ok {
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
}
.dot.bad {
  background: var(--red);
  box-shadow: 0 0 7px var(--red);
}

/* ----- Main ----- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Echoes of the Axon constellation, so the dashboard feels like the same
   * room — a faint pink glow top-right, indigo bottom-left. */
  background:
    radial-gradient(ellipse 48% 36% at 92% -4%, rgba(244, 114, 182, 0.05), transparent),
    radial-gradient(ellipse 46% 40% at 4% 104%, rgba(108, 99, 255, 0.06), transparent);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--sage), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.updated {
  font-size: 12px;
  color: var(--text-muted);
}

.btn {
  background: linear-gradient(150deg, var(--accent), var(--accent-dim));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font: 13px var(--font);
  cursor: pointer;
  box-shadow: 0 6px 16px -8px rgba(108, 99, 255, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: filter 150ms ease, transform 80ms ease;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn:active {
  transform: translateY(1px);
}
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  padding: 6px 10px;
  box-shadow: none;
}
.btn.ghost:hover {
  color: var(--text);
  border-color: var(--accent);
  filter: none;
}

.view {
  padding: 22px 24px;
  overflow-y: auto;
}
.hidden {
  display: none !important;
}

/* ----- Cards ----- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 28px -18px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 150ms ease, transform 120ms ease;
}
.card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-1px);
}
.card-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.card-value .unit {
  font-size: 15px;
  color: var(--text-muted);
  margin-left: 2px;
}

/* ----- Charts ----- */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 28px -18px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
}
.chart-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.plot {
  width: 100%;
}
.plot svg {
  display: block;
  width: 100%;
  height: auto;
}
.plot .axis {
  stroke: var(--border);
  stroke-width: 1;
}
.plot .grid {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.4;
  stroke-dasharray: 3 6;
}
.plot .tick {
  fill: var(--text-muted);
  font: 10px var(--mono);
}
.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 12px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 6px -1px currentColor;
}

/* ----- Explorer ----- */
.explorer {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}
.explorer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.metric-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 10px 28px -18px rgba(0, 0, 0, 0.7);
}
.metric-list li {
  padding: 9px 12px;
  font: 12px/1.4 var(--mono);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  word-break: break-all;
  transition: background 120ms ease, color 120ms ease;
}
.metric-list li:last-child {
  border-bottom: none;
}
.metric-list li:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.metric-list li.active {
  background: rgba(108, 99, 255, 0.16);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.empty {
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 48px;
  text-align: center;
}

/* ----- Nav badge + dashboard selector ----- */
.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 6px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  background: var(--red);
  color: #1a0c0c;
  box-shadow: 0 0 8px -1px var(--red);
}
.select.compact {
  width: auto;
  min-width: 150px;
  padding: 6px 9px;
  font-size: 12px;
}

/* ----- State badges + severities ----- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge.ok {
  background: rgba(52, 211, 153, 0.16);
  color: var(--green);
}
.badge.pending {
  background: rgba(251, 191, 36, 0.16);
  color: var(--amber);
}
.badge.firing {
  background: rgba(248, 113, 113, 0.18);
  color: var(--red);
}
.sev {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.sev.critical {
  color: var(--red);
}
.sev.warning {
  color: var(--amber);
}
.sev.info {
  color: var(--c-kai);
}

/* ----- Data table (Monitors) ----- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 28px -18px rgba(0, 0, 0, 0.7);
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg);
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table tbody tr:hover {
  background: var(--surface-hover);
}
.data-table .mono {
  font-family: var(--mono);
  font-size: 12px;
}
.mono-name {
  font-weight: 600;
}
.data-table .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ----- Alerts ----- */
.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 22px 0 12px;
}
.alerts-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.pill b {
  font-size: 18px;
  margin-right: 4px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pill.firing b {
  color: var(--red);
}
.pill.pending b {
  color: var(--amber);
}
.pill.ok b {
  color: var(--green);
}
.alert-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.alert-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.alert-card.firing {
  border-left-color: var(--red);
}
.alert-card.pending {
  border-left-color: var(--amber);
}
.alert-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.alert-name {
  font-weight: 600;
  flex: 1;
}
.alert-body {
  font-size: 12px;
  color: var(--text-muted);
}
.alert-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text);
}

/* ----- Timeline (alert history) ----- */
.timeline {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 0;
  box-shadow: 0 10px 28px -18px rgba(0, 0, 0, 0.7);
}
.timeline li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.timeline li:last-child {
  border-bottom: none;
}
.timeline li.muted {
  color: var(--text-muted);
  justify-content: center;
}
.tl-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 84px;
  flex-shrink: 0;
}
.tl-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.tl-dot.firing {
  background: var(--red);
  box-shadow: 0 0 7px var(--red);
}
.tl-dot.pending {
  background: var(--amber);
  box-shadow: 0 0 7px var(--amber);
}
.tl-dot.ok {
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
}
.tl-text .mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ----- Scrollbars (match the dark theme) ----- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3d4252;
}
::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 720px) {
  .sidebar {
    width: 64px;
  }
  .brand-text,
  .side-label,
  .nav-item,
  .status-text {
    display: none;
  }
  .explorer {
    grid-template-columns: 1fr;
  }
}
