/* Alfa Monitor — design tokens ported from Jellie CRM (platform/app/assets/css/tailwind.css):
   Inter Display 14/21 medium, neutral scale + brand green, 258px sidebar, 48px top bar,
   8px buttons with the gradient hairline, Jellie badge tones, 16px cards. White theme only. */

:root {
  /* Jellie scales */
  --neutral-0: #ffffff;
  --neutral-50: #f2f5f7;
  --neutral-100: #e3e8ee;
  --neutral-200: #b4b8c2;
  --neutral-300: #9398a5;
  --neutral-400: #737988;
  --neutral-500: #545a69;
  --neutral-600: #424857;
  --neutral-700: #212630;
  --neutral-800: #12151b;
  /* brand green (from the logo, calmer and deeper so white text on it stays readable) */
  --brand-0: #f3faf6;
  --brand-50: #e4f3eb;
  --brand-100: #c9e7d7;
  --brand-200: #a3d6bd;
  --brand-300: #6dbb96;
  --brand-400: #3a9d74;
  --brand-500: #1a7f5a;
  --brand-600: #12613f;
  --ink: #0a0a0a;

  /* semantic */
  --background: var(--neutral-0);
  --foreground: var(--neutral-800);
  --muted: var(--neutral-50);
  --muted-foreground: var(--neutral-600);
  --subtle: var(--neutral-400);
  --primary: var(--brand-500);
  --primary-hover: #16714f;
  --primary-active: #126346;
  --destructive: #e64341;
  --destructive-hover: #cf3c3b;
  --border: #d5d8de;
  --panel-border: #d9d9d9;
  --line: #d5dbe1;
  --card-border: #e5e7eb;
  --ring: #6dbb96;
  --list-active: #f0f7f3;

  --success: #1f8a5b;
  --success-soft: #f1fbef;
  --success-line: #d3eedb;
  --danger: #e64341;
  --danger-soft: #fff4f3;
  --danger-line: #fbd5d2;
  --warning: #b25700;
  --warning-soft: #fffaf3;
  --warning-line: #f4e6d2;
  --info-soft: #f2f9f5;
  --info-line: #d3eadf;

  --sidebar: #f9f9fa;
  --sidebar-foreground: var(--neutral-600);
  --sidebar-muted: #999999;
  --sidebar-icon: #9ca3af;
  --sidebar-accent: #e4efe9;

  /* badge tones (CChip) */
  --badge-default-fg: #6a7383;
  --badge-default-bg: #ebeef1;
  --badge-info-fg: #2e6a88;
  --badge-info-bg: #e7f3f6;
  --badge-info-border: #b4d0dd;
  --badge-positive-fg: #006908;
  --badge-positive-bg: #d7f7c2;
  --badge-positive-border: #a6eb84;
  --badge-negative-fg: #a82c00;
  --badge-negative-bg: #fcedb9;
  --badge-negative-border: #fcd579;
  --badge-warning-fg: #b3093c;
  --badge-warning-bg: #ffe7f2;
  --badge-warning-border: #ffccdf;

  --radius: 8px;
  --radius-card: 16px;
  --shadow-panel: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 4px 10px rgba(26, 127, 90, 0.04), 0 14px 36px rgba(26, 127, 90, 0.09);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.02);
  --ease: cubic-bezier(0.65, 0, 0.35, 1);

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-display: 'Inter Display', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 500 14px/21px var(--font-display);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.icon { flex: none; display: block; }
.muted { color: var(--subtle); }
.mono { font-family: var(--font-mono); }
[hidden] { display: none !important; }

::selection { background: var(--brand-50); }

* { scrollbar-width: thin; scrollbar-color: var(--neutral-100) transparent; }

/* ── shell ────────────────────────────────────────────── */

.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 258px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 0.5px solid var(--panel-border);
}
.sidebar-header { height: 56px; display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); font-weight: 500; }

.sidebar-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 12px; display: flex; flex-direction: column; gap: 24px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  padding: 0 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--sidebar-foreground);
  cursor: pointer;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item .icon { color: var(--sidebar-icon); transition: color 120ms; }
.nav-item:hover { background: rgba(0, 0, 0, 0.04); color: var(--ink); }
.nav-item:hover .icon { color: var(--ink); }
.nav-item.active { background: var(--sidebar-accent); color: var(--ink); font-weight: 600; }
.nav-item.active .icon { color: var(--primary); }
.nav-item .nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-meta { font-size: 12px; color: var(--sidebar-muted); font-weight: 500; }
.nav-empty { padding: 2px 8px; font-size: 13px; color: var(--sidebar-muted); }

/* sidebar: recent workflow runs */
.recent-runs { display: flex; flex-direction: column; gap: 6px; }
.run-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--neutral-0);
  transition: border-color 120ms, box-shadow 120ms;
}
.run-tile .node { margin-top: 2px; }
.run-tile:hover { border-color: var(--neutral-100); box-shadow: var(--shadow-soft); }
.run-tile.active { border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(26, 127, 90, 0.1); }
.run-tile-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.run-tile-top, .run-tile-sub { display: flex; align-items: baseline; gap: 8px; }
.run-tile-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--ink); }
.run-tile-time { font-size: 12px; color: var(--neutral-500); font-variant-numeric: tabular-nums; }
.run-tile-sub { font-size: 12px; color: var(--sidebar-muted); }
.run-tile-state { flex: 1; font-weight: 600; }
.run-tile-when { display: inline-flex; align-items: center; gap: 4px; }
.run-tile-platform { display: inline-flex; color: var(--neutral-400); }
.run-tile.passed .run-tile-state { color: var(--success); }
.run-tile.failed .run-tile-state, .run-tile.error .run-tile-state { color: #c22f2d; }
.run-tile.cancelled .run-tile-state { color: var(--warning); }
.run-tile.running .run-tile-state { color: var(--primary); }

.sidebar-footer { padding: 8px; border-top: 0.5px solid var(--panel-border); }
.device-card {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 2px 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: var(--neutral-0);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-soft);
}
.device-icon {
  grid-row: span 2;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--muted);
  color: var(--neutral-500);
  position: relative;
}
.device-icon .live-dot { position: absolute; right: -2px; top: -2px; }
.device-name { font-weight: 600; color: var(--ink); font-size: 13px; line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-sub { font-size: 12px; line-height: 16px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
}
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--subtle); }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--neutral-200); }
.crumbs .current { color: var(--ink); font-size: 16px; font-weight: 600; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-lead { display: flex; align-items: center; flex: none; }
.page-lead:empty { display: none; }
.segmented.platform-switch button { width: 32px; padding: 0; display: grid; place-items: center; }
.segmented.platform-switch button.on { color: var(--primary); }
.platform-tag { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 999px; background: var(--brand-0); border: 1px solid var(--brand-50); color: var(--primary); font-size: 12.5px; font-weight: 600; }
.page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.view { flex: 1; min-height: 0; overflow: hidden; position: relative; }

/* ── buttons (CButton) ────────────────────────────────── */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 0;
  background: none;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease-out, opacity 120ms, box-shadow 120ms;
  outline: none;
  flex: none;
}
.btn:focus-visible { box-shadow: 0 0 0 4px rgba(26, 127, 90, 0.22); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn .icon { width: 14px; height: 14px; }
.btn:has(> .icon:first-child) { padding-left: 8px; }

.btn-primary, .btn-destructive { color: #fff; font-weight: 500; }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); }
.btn-destructive { background: var(--destructive); }
.btn-destructive:hover { background: var(--destructive-hover); }
.btn-primary::after, .btn-destructive::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(66, 72, 87, 0) 0%, rgba(66, 72, 87, 0.72) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.btn-outline { border: 1px solid var(--border); color: var(--muted-foreground); background: var(--neutral-0); }
.btn-outline:hover { background: rgba(0, 0, 0, 0.04); }
.btn-outline:active { background: rgba(0, 0, 0, 0.08); }
.btn-text { color: var(--ink); padding: 0 6px; }
.btn-text:hover { opacity: 0.7; }
.btn-text.danger { color: var(--destructive); }
.btn-sm { height: 24px; padding: 0 8px; font-size: 13px; }
.btn-sm:has(> .icon:first-child) { padding-left: 6px; }
.btn-lg { height: 32px; }
.btn-icon { width: 28px; padding: 0 !important; }
.btn-icon.btn-sm { width: 24px; }

/* ── form controls ────────────────────────────────────── */

.select, .input {
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--neutral-0);
  padding: 0 10px;
  font-size: 13px;
  color: var(--foreground);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737988' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}
.select:hover, .input:hover { border-color: var(--neutral-200); }
.select:focus, .input:focus { border-color: var(--ring); box-shadow: 0 0 0 4px rgba(26, 127, 90, 0.16); }
.select-sm { height: 24px; font-size: 12px; padding-left: 8px; padding-right: 24px; background-position: right 7px center; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; color: var(--muted-foreground); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: var(--neutral-100);
  position: relative;
  transition: background 160ms var(--ease);
  flex: none;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  transition: transform 160ms var(--ease);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(12px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px rgba(26, 127, 90, 0.22); }

/* ── badges (CChip) ───────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--badge-default-bg);
  color: var(--badge-default-fg);
  font-size: 12px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  flex: none;
}
.badge .icon { width: 12px; height: 12px; }
.badge-info { border-color: var(--badge-info-border); background: var(--badge-info-bg); color: var(--badge-info-fg); }
.badge-positive { border-color: var(--badge-positive-border); background: var(--badge-positive-bg); color: var(--badge-positive-fg); }
.badge-negative { border-color: var(--badge-negative-border); background: var(--badge-negative-bg); color: var(--badge-negative-fg); }
.badge-warning { border-color: var(--badge-warning-border); background: var(--badge-warning-bg); color: var(--badge-warning-fg); }
.badge-running { border-color: var(--brand-100); background: var(--brand-0); color: var(--primary); }
.badge-outlined { background: transparent; border-color: var(--panel-border); color: var(--neutral-600); }

/* ── status primitives ────────────────────────────────── */

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
  flex: none;
  opacity: 0.9;
}
.spinner.sm { width: 12px; height: 12px; border-width: 1.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral-200); flex: none; }
.live-dot.on { background: #22c55e; }
.live-dot.warn { background: #f59e0b; }
.live-dot.off { background: var(--destructive); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--neutral-200); }
.dot.passed { background: var(--success); }
.dot.failed, .dot.error { background: var(--danger); }
.dot.running { background: var(--primary); animation: pulse 1.2s ease-in-out infinite; }
.dot.queued, .dot.pending { background: var(--neutral-200); }
.dot.cancelled { background: #f59e0b; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Status node: the round marker used in lists and the pipeline. */
.node {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--neutral-0);
  border: 1.5px dashed var(--neutral-200);
  color: var(--neutral-400);
  position: relative;
  transition: background 200ms, border-color 200ms, color 200ms;
}
.node .icon { width: 11px; height: 11px; stroke-width: 3; }
.node.sm { width: 16px; height: 16px; font-size: 9px; }
.node.sm .icon { width: 9px; height: 9px; stroke-width: 3.2; }
.node.sm.running::before { border-width: 1.5px; }
.node.idle { border-style: solid; border-color: var(--neutral-100); background: var(--muted); color: var(--neutral-400); }
.node.queued { border-style: solid; border-color: var(--brand-100); color: var(--primary); background: var(--brand-0); }
.node.running { border: 0; background: var(--brand-0); color: var(--primary); }
.node.running::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--brand-100);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
.node.passed { border: 0; background: var(--success); color: #fff; }
.node.failed, .node.error { border: 0; background: var(--danger); color: #fff; }
.node.cancelled { border: 0; background: #f59e0b; color: #fff; }
.node.skipped { border-style: solid; border-color: var(--neutral-100); color: var(--neutral-300); background: var(--neutral-0); }

.ticks { display: inline-flex; gap: 2px; align-items: flex-end; }
.tick { width: 4px; height: 14px; border-radius: 2px; background: var(--neutral-100); }
.tick.passed { background: #34b37a; }
.tick.failed, .tick.error { background: var(--danger); }

/* ── layout primitives ────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); height: 100%; }
.split.wide { grid-template-columns: minmax(400px, 520px) minmax(0, 1fr); }
.pane { min-height: 0; overflow: auto; }
.pane-left { border-right: 1px solid var(--card-border); background: var(--neutral-0); }
.pane-right { background: linear-gradient(180deg, #fbfbfd 0%, #f7f8fb 100%); display: flex; flex-direction: column; }

.section { padding: 20px 20px 8px; }
.section + .section { padding-top: 12px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); }
.count {
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  height: 18px;
  line-height: 18px;
  border-radius: 999px;
  background: var(--neutral-100);
  color: var(--neutral-600);
}
.section-head .spacer { flex: 1; }

.card {
  background: var(--neutral-0);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 40px 24px;
  color: var(--subtle);
  height: 100%;
}
.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  color: var(--primary);
  background: linear-gradient(180deg, var(--brand-0), var(--brand-50));
  border: 1px solid var(--brand-50);
}
.empty-icon .icon { width: 22px; height: 22px; }
.empty-title { color: var(--ink); font-weight: 600; font-size: 15px; }
.empty-text { max-width: 340px; font-size: 13px; line-height: 19px; }
.empty .btn { margin-top: 10px; }

/* ── tests page ───────────────────────────────────────── */

.test-list { display: flex; flex-direction: column; gap: 8px; }
.test-row {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  background: var(--neutral-0);
  cursor: pointer;
  transition: border-color 140ms, box-shadow 140ms, transform 140ms;
}
.test-row:hover { border-color: var(--neutral-100); box-shadow: var(--shadow-panel); }
.test-row.selected { border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(26, 127, 90, 0.12); }
.test-row-main { display: flex; align-items: flex-start; gap: 10px; }
.test-row-main > .node { margin-top: 3px; }
.test-row-text { flex: 1; min-width: 0; }
.test-row-title { color: var(--ink); font-weight: 600; line-height: 22px; }
.test-row-desc { font-size: 12.5px; line-height: 18px; color: var(--subtle); margin-top: 1px; }
.test-row-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-left: 26px; }
.test-row-foot .ticks { margin-left: auto; }

.run-list { display: flex; flex-direction: column; gap: 1px; }
.run-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 0;
  background: none;
  text-align: left;
  width: 100%;
  transition: background 120ms;
}
.run-row:hover { background: var(--muted); }
.run-row.selected { background: var(--list-active); }
.run-row-name { font-weight: 600; color: var(--ink); font-size: 13px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-row-sub { font-size: 12px; line-height: 16px; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-row-meta { font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; text-align: right; }

/* ── run viewer ───────────────────────────────────────── */

.rv { display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 20px 24px 20px; gap: 14px; }
.rv-head { display: flex; align-items: center; gap: 12px; }
.rv-title { flex: 1; min-width: 0; }
.rv-title h2 { font-size: 18px; line-height: 26px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-sub { font-size: 12.5px; color: var(--subtle); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.rv-sub span { display: inline-flex; align-items: center; gap: 4px; }
.rv-actions { display: flex; align-items: center; gap: 8px; }
.timer { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted-foreground); display: inline-flex; gap: 4px; align-items: center; }

.alert {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 19px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid;
}
.alert .icon { margin-top: 2px; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger-line); color: #a42b29; }
.alert-warn { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: var(--info-line); color: var(--primary); }
.alert-body { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 12px; }

.rv-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 14px; }
.rv-side { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; }
.panel { background: var(--neutral-0); border: 1px solid var(--card-border); border-radius: 14px; box-shadow: var(--shadow-soft); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--neutral-50); }
.panel-head h3 { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); flex: 1; }

.steps { list-style: none; margin: 0; padding: 6px; }
.steps li { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; position: relative; }
.steps li + li::before {
  content: '';
  position: absolute;
  left: 15.25px;
  top: -6px;
  height: 12px;
  width: 1.5px;
  background: var(--neutral-100);
}
.steps .step-name { font-size: 13px; line-height: 18px; color: var(--neutral-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps li.running { background: var(--brand-0); }
.steps li.running .step-name { color: var(--primary); font-weight: 600; }
.steps li.failed .step-name { color: #a42b29; }
.steps .step-time { font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.steps .step-error { grid-column: 2 / -1; font-size: 12px; line-height: 17px; color: #a42b29; white-space: pre-wrap; overflow-wrap: anywhere; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; padding: 10px; }
.shot {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--ink);
  aspect-ratio: 9 / 19.5;
  cursor: zoom-in;
  transition: transform 160ms var(--ease), box-shadow 160ms;
  padding: 0;
}
.shots.desktop { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.shots.desktop .shot { aspect-ratio: 16 / 10; border-radius: 8px; }
.shot:hover { transform: translateY(-2px); box-shadow: var(--shadow-panel); }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; }

.console { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.console-body {
  flex: 1;
  min-height: 160px;
  overflow: auto;
  padding: 8px 0;
  font: 12px/20px var(--font-mono);
  color: var(--neutral-700);
  background:
    linear-gradient(var(--neutral-0), var(--neutral-0)) padding-box;
}
.log-line { display: grid; grid-template-columns: 92px 46px minmax(0, 1fr); gap: 8px; padding: 0 14px; }
.log-line:hover { background: var(--muted); }
.log-line .ts { color: var(--neutral-200); }
.log-line .lvl { font-weight: 600; color: var(--neutral-300); font-size: 11px; }
.log-line .msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-line.lvl-step { margin-top: 6px; background: var(--brand-0); }
.log-line.lvl-step .lvl, .log-line.lvl-step .msg { color: var(--primary); font-weight: 600; }
.log-line.lvl-pass .lvl, .log-line.lvl-pass .msg { color: var(--success); }
.log-line.lvl-fail { background: var(--danger-soft); }
.log-line.lvl-fail .lvl, .log-line.lvl-fail .msg, .log-line.lvl-error .lvl, .log-line.lvl-error .msg { color: #c22f2d; }
.log-line.lvl-warn .lvl, .log-line.lvl-warn .msg { color: var(--warning); }
.log-line.placeholder { display: block; color: var(--subtle); font-style: italic; font-family: var(--font-display); }
.cursor-line { padding: 2px 14px; color: var(--primary); display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 12px; }

/* ── workflows list ───────────────────────────────────── */

.wf-page { height: 100%; overflow: auto; padding: 24px; }
.wf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; max-width: 1400px; }
.wf-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-card);
  border: 1px solid var(--card-border);
  background: var(--neutral-0);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: box-shadow 180ms var(--ease), transform 180ms var(--ease), border-color 180ms;
  position: relative;
  overflow: hidden;
}
.wf-card:hover { box-shadow: var(--shadow-card); transform: translateY(-2px); border-color: var(--neutral-100); }
.wf-card.running { border-color: var(--brand-100); }
.wf-card.running::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: sweep 1.4s var(--ease) infinite;
}
@keyframes sweep { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.wf-card-head { display: flex; align-items: flex-start; gap: 12px; }
.wf-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: linear-gradient(180deg, var(--brand-0), var(--brand-50));
  border: 1px solid var(--brand-50);
}
.wf-card-title { flex: 1; min-width: 0; }
.wf-card-title h3 { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-card-title p { font-size: 12.5px; color: var(--subtle); }
.wf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--neutral-50); background: var(--neutral-50); }
.wf-stat { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; background: var(--neutral-0); min-width: 0; }
.wf-stat dt { font-size: 11.5px; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-stat dd { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 600; line-height: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }
.wf-stat.bad dd::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: #c9302c; vertical-align: middle; }
.wf-stat .meter { height: 4px; margin-top: 2px; }
.wf-stat-none { color: var(--neutral-300); font-weight: 500; }
.wf-card-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--neutral-50); font-size: 12.5px; color: var(--subtle); }
.wf-card-foot .spacer { flex: 1; }

/* ── workflow builder / monitor ───────────────────────── */

.wf-left { display: flex; flex-direction: column; }
.wf-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--neutral-50); display: flex; flex-direction: column; gap: 12px; }
.title-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 2px 8px;
  margin-left: -8px;
  font-size: 20px;
  line-height: 30px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  outline: none;
  transition: border-color 120ms, background 120ms;
}
.title-input:hover { background: var(--muted); }
.title-input:focus { border-color: var(--ring); background: var(--neutral-0); box-shadow: 0 0 0 4px rgba(26, 127, 90, 0.14); }
.wf-settings { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted-foreground); }
.field-inline { display: inline-flex; align-items: center; gap: 8px; }

.wf-bar { display: flex; align-items: center; gap: 8px; padding: 14px 20px 10px; }
.wf-bar .spacer { flex: 1; }
.run-banner {
  margin: 12px 16px 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.run-banner .spacer { flex: 1; }

.pipeline { list-style: none; margin: 0; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.pipe-step {
  display: grid;
  grid-template-columns: auto 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 8px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: var(--neutral-0);
  box-shadow: var(--shadow-soft);
  position: relative;
  transition: border-color 200ms, box-shadow 200ms, background 200ms;
  user-select: none;
}
/* rail between nodes, spanning the 10px gap above each step */
.pipe-step + .pipe-step::before {
  content: '';
  position: absolute;
  top: -11px;
  height: 10px;
  width: 2px;
  left: var(--rail-x, 49px);
  background: var(--neutral-100);
  border-radius: 2px;
}
.pipeline.run .pipe-step { grid-template-columns: 24px minmax(0, 1fr) auto; padding-left: 12px; cursor: pointer; --rail-x: 23px; }
.pipeline.run .pipe-step:hover { border-color: var(--neutral-100); }
.pipe-step.running { border-color: var(--brand-100); background: linear-gradient(90deg, var(--brand-0), var(--neutral-0) 60%); }
.pipe-step.running::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: sweep 1.3s var(--ease) infinite;
}
.pipe-step.passed { background: linear-gradient(90deg, var(--success-soft), var(--neutral-0) 60%); border-color: var(--success-line); }
.pipe-step.failed, .pipe-step.error { background: linear-gradient(90deg, var(--danger-soft), var(--neutral-0) 60%); border-color: var(--danger-line); }
.pipe-step.skipped { opacity: 0.6; }
/* After the status rules so the selection border wins over green/red; darker than the light "passed" outline. */
.pipeline.run .pipe-step.selected { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(26, 127, 90, 0.14); }
.pipe-step.passed + .pipe-step::before { background: #8fd3b1; }
.pipe-step-text { min-width: 0; }
.pipe-step-name { color: var(--ink); font-weight: 600; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-step-sub { font-size: 12px; line-height: 17px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-step.failed .pipe-step-sub, .pipe-step.error .pipe-step-sub { color: #c22f2d; }
.pipe-step-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.pipe-step .remove { opacity: 0; transition: opacity 120ms; color: var(--neutral-400); }
.pipe-step:hover .remove { opacity: 1; }
.pipe-step .remove:hover { color: var(--destructive); opacity: 1; }
.drag-handle {
  width: 20px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--neutral-200);
  cursor: grab;
  border-radius: 6px;
  touch-action: none;
}
.drag-handle:hover { color: var(--neutral-500); background: var(--muted); }
.pipe-step.dragging {
  z-index: 5;
  cursor: grabbing;
  box-shadow: 0 18px 40px rgba(26, 127, 90, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);
  border-color: var(--brand-200);
  transition: box-shadow 200ms, border-color 200ms;
}
.pipe-step.dragging::before { display: none; }
.pipeline.sorting .pipe-step:not(.dragging) { transition: transform 180ms var(--ease); }
.pipeline.sorting .pipe-step::before { opacity: 0; }

.add-zone {
  margin: 4px 16px 16px;
  border: 1.5px dashed var(--neutral-100);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--subtle);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 140ms, color 140ms, background 140ms;
  background: none;
  width: calc(100% - 32px);
}
.add-zone:hover { border-color: var(--brand-200); color: var(--primary); background: var(--brand-0); }

.history { padding: 4px 16px 24px; margin-top: auto; border-top: 1px solid var(--neutral-50); }
.history .section-head { padding: 14px 4px 0; }
.history-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  font-size: 13px;
}
.history-row:hover { background: var(--muted); }
.history-row.selected { background: var(--list-active); }
.history-row .when { color: var(--neutral-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-row .meta { font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.segments { display: inline-flex; gap: 2px; }
.segments i { width: 6px; height: 6px; border-radius: 2px; background: var(--neutral-100); }
.segments i.passed { background: #34b37a; }
.segments i.failed, .segments i.error { background: var(--danger); }
.segments i.running, .segments i.queued { background: var(--primary); }
.segments i.cancelled { background: #f59e0b; }

/* monitor (right side of the workflow page) */
.monitor-head { padding: 20px 24px 0; display: flex; flex-direction: column; gap: 12px; }
.monitor-top { display: flex; align-items: center; gap: 12px; }
.monitor-title { flex: 1; min-width: 0; }
.monitor-title .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); display: flex; align-items: center; gap: 6px; }
.monitor-title h2 { font-size: 18px; font-weight: 600; color: var(--ink); line-height: 26px; }
.progress { display: flex; gap: 4px; height: 6px; }
.progress i { flex: 1; border-radius: 3px; background: var(--neutral-100); position: relative; overflow: hidden; transition: background 300ms; }
.progress i.passed { background: #34b37a; }
.progress i.failed, .progress i.error { background: var(--danger); }
.progress i.cancelled { background: #f59e0b; }
.progress i.skipped { background: var(--neutral-50); }
.progress i.queued { background: var(--brand-100); }
.progress i.running { background: var(--brand-100); }
.progress i.running::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 60% 100%;
  background-repeat: no-repeat;
  animation: sweep 1.2s var(--ease) infinite;
}
.monitor-stats { display: flex; gap: 18px; font-size: 12.5px; color: var(--subtle); }
.monitor-stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.monitor-body { flex: 1; min-height: 0; }

/* ── popover / modal / toast / lightbox ───────────────── */

.popover {
  position: fixed;
  z-index: 50;
  width: 360px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--neutral-0);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow-panel), 0 20px 50px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  animation: pop 140ms var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.popover-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border-bottom: 1px solid var(--neutral-50); color: var(--subtle); }
.popover-search input { flex: 1; border: 0; outline: none; background: none; font-size: 14px; color: var(--ink); }
.popover-list { overflow: auto; padding: 6px; }
.option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
}
.option:hover, .option.active { background: var(--list-active); }
.option-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-0); color: var(--primary); }
.option-name { color: var(--ink); font-weight: 600; font-size: 13px; line-height: 18px; }
.option-desc { font-size: 12px; line-height: 16px; color: var(--subtle); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.popover-empty { padding: 20px; text-align: center; color: var(--subtle); font-size: 13px; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(18, 21, 27, 0.4);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  animation: fade 160ms ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(420px, calc(100vw - 32px));
  background: var(--neutral-0);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card), 0 30px 80px rgba(15, 23, 42, 0.25);
  padding: 20px;
  animation: pop 160ms var(--ease);
}
.modal h3 { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.modal p { color: var(--muted-foreground); font-size: 13.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.lightbox { cursor: zoom-out; background: rgba(10, 12, 16, 0.82); }
.lightbox img { max-height: 92vh; max-width: 92vw; border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); animation: pop 180ms var(--ease); }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--neutral-0);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-panel), 0 12px 30px rgba(15, 23, 42, 0.1);
  font-size: 13px;
  color: var(--ink);
  animation: slideIn 200ms var(--ease);
}
.toast.error .icon { color: var(--destructive); }
.toast.success .icon { color: var(--success); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 200ms; }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } }

.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--subtle); padding-right: 4px; }
.save-state .icon { color: var(--success); }

/* ── responsive ───────────────────────────────────────── */

@media (max-width: 1280px) {
  .rv-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(260px, 1fr); }
  .rv-side { flex-direction: row; overflow: visible; }
  .rv-side > .panel { flex: 1; min-width: 0; }
}
@media (max-width: 1080px) {
  .split, .split.wide { grid-template-columns: 1fr; grid-template-rows: auto minmax(560px, 1fr); overflow: auto; }
  .pane-left { border-right: 0; border-bottom: 1px solid var(--card-border); overflow: visible; }
  .view { overflow: auto; }
}
@media (max-width: 860px) {
  .sidebar { width: 60px; }
  .brand-text, .nav-text, .nav-meta, .nav-label, .nav-group.recent, .device-card > :not(.device-icon) { display: none; }
  .device-card { grid-template-columns: 1fr; justify-items: center; padding: 8px; }
  .nav-item { justify-content: center; }
  .topbar { padding: 0 16px; }
}

/* ── dashboard (layout after Jellie CRM's /dashboard) ─── */

.dash-page { height: 100%; overflow: auto; }
.dash { max-width: 1400px; margin: 0 auto; padding: 20px 20px 32px; display: flex; flex-direction: column; gap: 14px; }
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.dash-head h1 { font-size: 22px; line-height: 32px; font-weight: 600; color: #000; }
.dash-head p { font-size: 14px; line-height: 20px; color: var(--neutral-400); }
.dash-body { display: flex; flex-direction: column; gap: 12px; transition: opacity 200ms; }
.dash-body.refetching { opacity: 0.55; }
.dash-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 80px 0; color: var(--subtle); }

/* segmented control (Jellie ToggleGroup) */
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius); background: var(--muted); border: 1px solid var(--neutral-50); }
.segmented button {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--neutral-500);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.segmented button:hover { background: rgba(232, 234, 237, 0.64); color: var(--ink); }
.segmented button.on { background: var(--neutral-0); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--neutral-100); }

/* health banner – status colour always paired with an icon + text */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid; }
.banner-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.banner-icon .icon { stroke-width: 2.6; width: 12px; height: 12px; }
.banner-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.banner-text b { color: var(--ink); font-weight: 600; }
.banner-text span { color: var(--muted-foreground); font-size: 13px; }
.banner.good { background: var(--success-soft); border-color: var(--success-line); }
.banner.good .banner-icon { background: #3fae79; }
.banner.critical { background: var(--danger-soft); border-color: var(--danger-line); }
.banner.critical .banner-icon { background: #c9302c; }
.banner.warn { background: var(--warning-soft); border-color: var(--warning-line); }
.banner.warn .banner-icon { background: #e9a23b; }
.banner.neutral { background: var(--info-soft); border-color: var(--info-line); }
.banner.neutral .banner-icon { background: var(--primary); }

/* stat cards (Jellie DashboardStatCard) */
.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat-card { min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--neutral-0); overflow: hidden; }
.stat-top { display: flex; align-items: center; gap: 8px; }
.stat-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--neutral-50); color: var(--neutral-500); flex: none; }
.stat-label { flex: 1; min-width: 0; font-size: 13px; line-height: 20px; color: var(--neutral-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; min-height: 36px; }
.stat-value { font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; }
.stat-main .spark { flex: none; max-width: 50%; }
.stat-hint { font-size: 12px; line-height: 16px; color: var(--neutral-400); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.delta .icon { width: 12px; height: 12px; stroke-width: 2.2; }
.delta.up { background: var(--badge-positive-bg); color: var(--badge-positive-fg); }
.delta.down { background: #ffeae1; color: #a9271f; }
.delta.flat { background: var(--neutral-50); color: var(--neutral-500); }
.delta.new { background: var(--brand-50); color: var(--primary); }

/* cards and rows */
.dash-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dash-card { min-width: 0; display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--neutral-0); }
.dash-card.span-2 { grid-column: span 2; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 16px; }
.card-head > div:first-child { flex: 1; min-width: 180px; }
.card-head h2 { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink); }
.card-sub { font-size: 12px; line-height: 16px; color: var(--neutral-400); font-variant-numeric: tabular-nums; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 12px; line-height: 20px; color: var(--neutral-500); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.key-line { width: 12px; height: 2px; border-radius: 1px; display: inline-block; flex: none; }
.key-rect { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }

/* charts */
.chart { position: relative; min-height: 200px; }
.chart svg { display: block; overflow: visible; }
.chart .axis-text { font: 500 11px var(--font-display); fill: #9398a5; font-variant-numeric: tabular-nums; }
.chart .end-label { font: 600 12px var(--font-display); fill: var(--neutral-600); }
.chart svg.dimmed .col:not(.on) { opacity: 0.35; }
.chart .col { transition: opacity 120ms; }
.chart .hit, .chart .overlay { outline: none; cursor: crosshair; }
.chart .hit:focus-visible, .chart .overlay:focus-visible { stroke: var(--ring); stroke-width: 2; }
.chart.is-empty::after {
  content: 'No runs in this period';
  position: absolute;
  inset: 0 0 24px 34px;
  display: grid;
  place-items: center;
  color: var(--neutral-400);
  font-size: 13px;
  pointer-events: none;
}
.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 150px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--neutral-0);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-panel);
  font-size: 12px;
  line-height: 18px;
}
.chart-tip-title { color: var(--neutral-500); margin-bottom: 4px; white-space: nowrap; }
.chart-tip-row { display: grid; grid-template-columns: 12px auto 1fr; align-items: center; gap: 6px; white-space: nowrap; }
.chart-tip-row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip-row span:last-child { color: var(--neutral-500); }

.chart-table { max-height: 260px; overflow: auto; }
.chart-empty { padding: 28px 0; text-align: center; color: var(--neutral-400); font-size: 13px; }
.chart-empty a { color: var(--primary); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { height: 28px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--neutral-400); border-bottom: 0.5px solid var(--panel-border); padding: 0 8px; white-space: nowrap; }
.data-table td { height: 36px; padding: 4px 8px; border-bottom: 0.5px solid var(--neutral-50); color: var(--neutral-700); font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.wf-table tbody tr { cursor: pointer; transition: background 120ms; }
.wf-table tbody tr:hover, .wf-table tbody tr:focus-visible { background: var(--list-active); outline: none; }
.wf-name { color: var(--ink); font-weight: 600; }
.wf-sub { font-size: 12px; }

/* test health meters: fill carries severity, track is a lighter step of the same hue */
.health-list { display: flex; flex-direction: column; gap: 4px; }
.health-row { display: flex; flex-direction: column; gap: 6px; padding: 10px; margin: 0 -10px; border-radius: 10px; transition: background 120ms; }
.health-row:hover { background: var(--muted); }
.health-top { display: flex; align-items: center; gap: 8px; }
.health-name { flex: 1; min-width: 0; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-rate { font-weight: 600; color: var(--ink); }
.meter { height: 6px; border-radius: 3px; overflow: hidden; background: var(--neutral-50); }
.meter span { display: block; height: 100%; border-radius: 3px; transition: width 400ms var(--ease); }
.meter.good { background: #dff3e8; }
.meter.good span { background: #3fae79; }
.meter.warn { background: #fbeed6; }
.meter.warn span { background: #e9a23b; }
.meter.critical { background: #f8dcdb; }
.meter.critical span { background: #c9302c; }
.health-meta { display: flex; gap: 10px; font-size: 12px; color: var(--neutral-400); }
.health-meta span:first-child { flex: 1; }

/* recent failures */
.failure-list { display: flex; flex-direction: column; gap: 2px; max-height: 300px; overflow: auto; margin: 0 -8px; }
.failure-row { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; padding: 8px; border-radius: 10px; transition: background 120ms; }
.failure-row:hover { background: var(--muted); }
.failure-row > .node { margin-top: 2px; }
.failure-head { display: flex; gap: 8px; align-items: baseline; }
.failure-head b { flex: 1; color: var(--ink); font-weight: 600; font-size: 13px; }
.failure-head span { font-size: 12px; color: var(--neutral-400); white-space: nowrap; }
.failure-error { font: 12px/17px var(--font-mono); color: #a42b29; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 2px; }
.failure-meta { font-size: 12px; color: var(--neutral-400); margin-top: 2px; }
.all-clear { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 0; text-align: center; color: var(--neutral-400); font-size: 13px; }
.all-clear b { color: var(--ink); font-size: 14px; }

/* live now */
.live-device { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--muted); }
.live-list { display: flex; flex-direction: column; gap: 2px; margin: 8px -8px 0; }
.live-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; font-size: 13px; }
.live-row:hover { background: var(--muted); }
.live-row b { color: var(--ink); font-weight: 600; }
.live-row .muted { font-size: 12px; }
.live-idle { display: flex; align-items: center; gap: 8px; padding: 18px 4px 4px; color: var(--neutral-400); font-size: 13px; }

@media (max-width: 1400px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .dash-row { grid-template-columns: 1fr; }
  .dash-card.span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash { padding: 16px; }
}

/* ── sign-in ──────────────────────────────────────────── */

body.auth-pending .app, body.signed-out .app { display: none; }
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 50% 0%, var(--brand-0) 0%, var(--background) 60%);
}
.login[hidden] { display: none; }
.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 28px 24px;
  background: var(--neutral-0);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.login-logo { width: 40px; height: 40px; }
.login-head h1 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; color: var(--ink); }
.login-head p { margin: 2px 0 6px; font-size: 13px; line-height: 18px; color: var(--subtle); }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink); }
.login-field .input { height: 36px; font-size: 14px; }
.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--danger-line);
  background: var(--danger-soft);
  color: #b42b29;
  font-size: 13px;
  line-height: 18px;
}
.login-error[hidden] { display: none; }
.login-error .icon { flex: none; }
.btn-block { width: 100%; height: 36px; margin-top: 4px; }

/* signed-in user, under the device card */
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px 2px; }
.user-row[hidden] { display: none; }
.user-avatar {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-50);
  color: var(--brand-600);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 11px; line-height: 14px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout { color: var(--muted-foreground); font-weight: 500; }
.user-logout:hover { color: var(--destructive); opacity: 1; }
@media (max-width: 860px) {
  .user-row { justify-content: center; padding: 8px 0 0; }
  .user-avatar, .user-meta, .user-logout .btn-label { display: none; }
}
