/* Relay Dashboard Design System */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Colors - Light Theme (Engineered Graphite & Technical Cobalt) */
  --bg-app: #f6f8fa;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f3f4f6;
  --bg-surface-sunken: #eaeef2;
  --border: #d0d7de;
  --border-strong: #afb8c1;

  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-tertiary: #6e7781;

  --color-primary: #0969da;
  --color-primary-hover: #0854ad;
  --color-success: #1a7f37;
  --color-success-bg: #dafbe1;
  --color-success-text: #116329;
  --color-error: #cf222e;
  --color-error-bg: #ffebe9;
  --color-error-text: #a40e26;
  --color-warning: #9a6700;
  --color-warning-bg: #fff8c5;
  --color-warning-text: #7d4e00;
  --color-info: #0969da;
  --color-info-bg: #ddf4ff;
  --color-info-text: #0550ae;
  --color-purple: #0891b2;
  --color-purple-bg: #e0f2fe;
  --color-purple-text: #0369a1;

  --sidebar-width: 240px;
  --sidebar-folded-width: 60px;
  --header-height: 56px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
  /* Colors - Dark Theme (Obsidian & Steel Cyan) */
  --bg-app: #0d1117;
  --bg-surface: #161b22;
  --bg-surface-raised: #21262d;
  --bg-surface-sunken: #010409;
  --border: #30363d;
  --border-strong: #484f58;

  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;

  --color-primary: #4493f8;
  --color-primary-hover: #58a6ff;
  --color-success: #3fb950;
  --color-success-bg: #0d2d14;
  --color-success-text: #56d364;
  --color-error: #f85149;
  --color-error-bg: #3b1219;
  --color-error-text: #ff7b72;
  --color-warning: #d29922;
  --color-warning-bg: #382805;
  --color-warning-text: #e3b341;
  --color-info: #58a6ff;
  --color-info-bg: #0c2d6b;
  --color-info-text: #79c0ff;
  --color-purple: #38bdf8;
  --color-purple-bg: #082f49;
  --color-purple-text: #7dd3fc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

::selection {
  background: rgba(9, 105, 218, 0.2);
  color: inherit;
}

[data-theme="dark"] ::selection {
  background: rgba(68, 147, 248, 0.3);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--color-primary);
}

/* Numerals in technical data */
table.data-table,
.stat-value,
.node-duration,
.node-step-id,
.relative-time,
.badge,
.pill,
.kpi-sub-pill,
.group-card-meta {
  font-variant-numeric: tabular-nums lining-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge-info {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  border-color: rgba(68, 147, 248, 0.25);
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border-color: rgba(63, 185, 80, 0.25);
}

.badge-neutral {
  background: var(--bg-surface-raised);
  color: var(--text-tertiary);
  border-color: var(--border);
}

/* App Shell */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
}

.sidebar.folded {
  width: var(--sidebar-folded-width);
}

.sidebar.folded .brand-text,
.sidebar.folded .brand-badge,
.sidebar.folded .nav-label,
.sidebar.folded .sidebar-footer-text,
.sidebar.folded .theme-text,
.sidebar.folded .sidebar-fold-toggle {
  display: none;
}

.sidebar.folded .sidebar-header {
  padding: 0 8px;
  justify-content: center;
}

.sidebar-hover-expand {
  display: none;
}

.sidebar.folded .brand-logo {
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  position: relative;
  transition: all 0.15s ease;
  cursor: pointer;
}

.sidebar.folded .brand-logo:hover {
  background: var(--bg-surface-raised);
}

.sidebar.folded .brand-logo:hover .brand-logo-svg {
  display: none;
}

.sidebar.folded .brand-logo:hover .sidebar-hover-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.sidebar.folded .nav-item {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.folded .nav-item svg {
  margin: 0;
  width: 20px;
  height: 20px;
}

.sidebar.folded .sidebar-footer {
  padding: 10px 4px;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sidebar.folded .sidebar-footer-actions {
  flex-direction: column;
  width: 100%;
  align-items: center;
  gap: 6px;
}

.sidebar.folded .sidebar-footer-actions button {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-badge {
  background: var(--color-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.sidebar-fold-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: all 0.15s ease;
}

.sidebar-fold-toggle:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border-color: var(--border);
}

.sidebar-nav {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--color-primary);
  color: #fff;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-tertiary);
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main Container */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Header */
.top-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  overflow: hidden;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-sm {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
}

/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Status Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.pill-success { background: var(--color-success-bg); color: var(--color-success-text); }
.pill-success .dot { background: var(--color-success); }

.pill-info { background: var(--color-info-bg); color: var(--color-info-text); }
.pill-info .dot { background: var(--color-info); }

.pill-error { background: var(--color-error-bg); color: var(--color-error-text); }
.pill-error .dot { background: var(--color-error); }

.pill-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
.pill-warning .dot { background: var(--color-warning); }

.pill-purple { background: var(--color-purple-bg); color: var(--color-purple-text); }
.pill-purple .dot { background: var(--color-purple); }

.pill-neutral { background: var(--bg-surface-raised); color: var(--text-secondary); }
.pill-neutral .dot { background: var(--text-tertiary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-surface-raised);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-xs {
  padding: 2px 6px;
  font-size: 11px;
}

.hotkey-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-sunken);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  margin-left: 6px;
  line-height: 1;
}

/* Cards & Tables */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

/* Empty & Operational Notice States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.empty-state-icon.icon-offline {
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
  border-color: rgba(210, 153, 34, 0.4);
}

.empty-state-icon.icon-error {
  color: var(--color-error-text);
  background: var(--color-error-bg);
  border-color: rgba(248, 81, 73, 0.4);
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.empty-state-hint {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--bg-surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: left;
  width: 100%;
}

.empty-state-hint code {
  color: var(--color-primary);
  font-family: inherit;
  font-weight: 500;
}

.empty-state-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.table-container {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

table.data-table th {
  background: var(--bg-surface-raised);
  padding: 10px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr.clickable {
  cursor: pointer;
}

table.data-table tr.clickable:hover td {
  background: var(--bg-surface-raised);
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Toolbar & Filters */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.input-text {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  outline: none;
}
.input-text:focus {
  border-color: var(--color-primary);
}

/* DAG Canvas & Viewport */
.dag-container {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-sunken);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.dag-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-surface-raised);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.dag-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.status-success { background: var(--color-success); }
.legend-dot.status-running { background: var(--color-info); }
.legend-dot.status-error { background: var(--color-error); }
.legend-dot.status-child { background: var(--color-purple); }

.dag-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dag-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-surface-raised);
}

.dag-btn:active {
  background: var(--bg-surface-sunken);
}

.dag-viewport {
  width: 100%;
  height: 380px;
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
}

.dag-viewport:active {
  cursor: grabbing;
}

.dag-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-grid-bg {
  pointer-events: none;
}

/* DAG Group Cards & Nodes */
.dag-group-card .group-card-bg {
  fill: var(--bg-surface);
  stroke: var(--border);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.04));
}

.dag-group-card.child-group .child-card-border {
  stroke: var(--color-purple);
  stroke-dasharray: 4 2;
}

.dag-group-card .group-card-header-bg {
  fill: var(--bg-surface-raised);
}

.dag-group-card .group-card-header-fill {
  fill: var(--bg-surface-raised);
}

.group-card-title {
  font-size: 12px;
  font-weight: 700;
  fill: var(--text-primary);
}

.group-card-meta {
  font-size: 11px;
  fill: var(--text-tertiary);
}

.child-card-action .action-pill-bg {
  fill: var(--color-primary);
  opacity: 0.12;
  transition: opacity 0.15s ease;
}

.child-card-action:hover .action-pill-bg {
  opacity: 0.25;
}

.child-card-action .action-pill-text {
  font-size: 11px;
  font-weight: 600;
  fill: var(--color-primary);
}

.child-empty-text {
  font-size: 11px;
  fill: var(--text-tertiary);
  font-style: italic;
}

.dag-node .node-bg {
  fill: var(--bg-surface);
  stroke: var(--border-strong);
  stroke-width: 1;
  transition: all 0.2s ease;
}

.dag-node:hover .node-bg {
  stroke: var(--color-primary);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.08));
}

.dag-node .node-step-id {
  font-size: 11px;
  font-weight: 700;
  fill: var(--text-secondary);
  font-family: var(--font-mono);
}

.dag-node .node-name {
  font-size: 12px;
  font-weight: 600;
  fill: var(--text-primary);
}

.dag-node .node-status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.dag-node .node-duration {
  font-size: 11px;
  fill: var(--text-secondary);
  font-family: var(--font-mono);
}

.dag-edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 2;
  stroke-dasharray: 4 2;
}

.dag-family-edge {
  fill: none;
  stroke-width: 2;
  stroke-dasharray: 6 3;
}

.dag-family-edge.edge-success { stroke: var(--color-success); }
.dag-family-edge.edge-error { stroke: var(--color-error); }
.dag-family-edge.edge-running { stroke: var(--color-info); }
.dag-family-edge.edge-default { stroke: var(--border-strong); }

.dag-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-tertiary);
  gap: 12px;
}

.dag-empty-icon {
  width: 48px;
  height: 48px;
}

/* Status-Aware Breadcrumbs */
.wf-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

.wf-breadcrumb-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.wf-breadcrumb-link:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.wf-breadcrumb-separator {
  color: var(--text-tertiary);
  font-size: 12px;
}

.wf-breadcrumb-current {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-strong);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.dot-success { background: var(--color-success); }
.status-dot.dot-error { background: var(--color-error); }
.status-dot.dot-running { background: var(--color-info); }
.status-dot.dot-pending { background: var(--text-tertiary); }

/* Tabs */
.tab-list {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* JSON Viewer */
.json-viewer {
  background: var(--bg-surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}

.json-header {
  padding: 6px 12px;
  background: var(--bg-surface-raised);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.json-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.json-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.json-title {
  font-weight: 600;
  color: var(--text-secondary);
}

.json-segment-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.json-segment-btn {
  background: var(--bg-surface);
  border: none;
  color: var(--text-secondary);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.json-segment-btn.active {
  background: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
}

.json-content {
  padding: 12px;
  overflow-x: auto;
  max-height: 360px;
}

.json-content code {
  white-space: pre-wrap;
  word-break: break-all;
}

.json-key { color: var(--color-primary); font-weight: 600; }
.json-string { color: #0a7d57; }
.json-number { color: #b45309; }
.json-boolean { color: #0550ae; }
.json-null { color: var(--text-tertiary); }

[data-theme="dark"] .json-string { color: #7ee787; }
[data-theme="dark"] .json-number { color: #e3b341; }
[data-theme="dark"] .json-boolean { color: #79c0ff; }

/* Actionable KPI Cards & Sub-pills */
.stat-card .stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.kpi-subtext {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-sub-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.kpi-sub-pill.kpi-info {
  color: var(--color-info-text);
  border-color: var(--color-info-border);
  background: var(--color-info-bg);
}

.kpi-sub-pill.kpi-error {
  color: var(--color-error-text);
  border-color: var(--color-error-border);
  background: var(--color-error-bg);
}

.kpi-sub-pill.kpi-success {
  color: var(--color-success-text);
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
}

.relative-time {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Modal Dialog Large for Fullscreen Payload */
.modal-dialog-large {
  max-width: 820px;
  width: 92%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-dialog-large .modal-body {
  overflow-y: auto;
  flex: 1;
}

/* Focus and Keyboard Accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.dag-node:focus-visible .node-bg {
  stroke: var(--color-primary);
  stroke-width: 2;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

table.data-table tr.clickable:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .modal-dialog,
  .drawer-panel,
  .toast {
    animation: fadeIn 0.15s ease-out;
    transform: none !important;
  }
  .spinner {
    animation: none;
    opacity: 0.7;
  }
}

/* Loading Spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.loading-spinner::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Live Telemetry Polling */
.poll-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
}

.poll-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  display: inline-block;
  transition: background-color 0.2s ease;
}

.poll-dot.active {
  background: var(--color-success);
}

.poll-dot.error {
  background: var(--color-warning);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease-out;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  animation: scaleIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-raised);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Slide-Over Inspector Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease-out;
}

.drawer-panel {
  width: 100%;
  max-width: 540px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.drawer-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface-raised);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* Confirmation Dialog & Consequence Box */
.confirm-consequence {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-error-text);
  line-height: 1.45;
}

.confirm-warning {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-warning-text);
  line-height: 1.45;
}

.confirm-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--bg-surface-raised);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.confirm-meta-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.confirm-meta-table tr:last-child td {
  border-bottom: none;
}

.confirm-meta-table td:first-child {
  font-weight: 600;
  color: var(--text-secondary);
  width: 130px;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 420px;
}

.toast-success {
  border-color: var(--color-success);
}

.toast-error {
  border-color: var(--color-error);
  color: var(--color-error-text);
}

.toast-info {
  border-color: var(--color-primary);
}

@keyframes toastIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Forms */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Responsive Layout */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.mobile-nav-toggle:hover {
  background: var(--bg-surface-raised);
}

.mobile-nav-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

.mobile-overlay {
  display: none;
}

@media (max-width: 900px) {
  .header-right .selector-group label {
    display: none;
  }
  .header-right .poll-indicator span:last-child {
    display: none;
  }
  .header-right .hotkey-badge {
    display: none;
  }
}

@media (max-width: 768px) {
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-fold-toggle {
    display: none !important;
  }

  .sidebar.folded {
    width: var(--sidebar-width);
  }

  .sidebar.folded .brand-text,
  .sidebar.folded .brand-badge,
  .sidebar.folded .nav-label,
  .sidebar.folded .sidebar-footer-text,
  .sidebar.folded .theme-text {
    display: initial;
  }

  .sidebar.folded .nav-item {
    justify-content: flex-start;
    padding: 8px 12px;
  }

  .sidebar.folded .sidebar-footer {
    flex-direction: row;
    padding: 12px 16px;
  }

  .sidebar.folded .sidebar-footer-actions {
    flex-direction: row;
    width: auto;
  }

  .sidebar.folded .sidebar-footer-actions button {
    width: auto;
    height: auto;
    padding: 4px 8px;
  }

  .sidebar.folded .sidebar-collapse-btn {
    display: none !important;
  }

  .mobile-overlay.active {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 80;
    animation: fadeIn 0.15s ease-out;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 90;
    transition: left 0.25s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .top-header {
    padding: 0 16px;
    gap: 8px;
  }

  .content-area {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .input-text {
    width: 100%;
  }

  .drawer-panel {
    max-width: 100%;
  }

  .btn {
    min-height: 40px;
    padding: 8px 14px;
  }

  .btn-xs {
    min-height: 32px;
    padding: 4px 10px;
  }

  .nav-item {
    min-height: 44px;
    padding: 10px 14px;
  }
}
