/* Theme Color Tokens */
:root[data-theme="dark"] {
  --pico-font-size: 88%;
  --bg-base: #000000;
  --bg-surface: #0a0a0a;
  --bg-surface-elevated: #141414;
  --bg-surface-hover: #1f1f1f;
  --border-subtle: #222222;
  --border-focus: #444444;
  --text-main: #ffffff;
  --text-muted: #888888;
  --text-subtle: #555555;
  
  /* Semantic Chart Colors */
  --chart-green: #22c55e;
  --chart-green-dim: rgba(34, 197, 94, 0.18);
  --chart-yellow: #eab308;
  --chart-yellow-dim: rgba(234, 179, 8, 0.18);
  --chart-red: #ef4444;
  --chart-red-dim: rgba(239, 68, 68, 0.18);
  --chart-gray: #8a8a8a;

  /* Categorical series, in fixed order (reference palette, dark steps) */
  --viz-1: #3987e5;
  --viz-2: #d95926;
  --viz-3: #199e70;
  --viz-4: #c98500;
  --viz-5: #d55181;
  --viz-6: #008300;
  --viz-7: #9085e9;
  --viz-8: #e66767;
}

:root[data-theme="light"] {
  --pico-font-size: 88%;
  --bg-base: #ffffff;
  --bg-surface: #fbfbfb;
  --bg-surface-elevated: #f4f4f5;
  --bg-surface-hover: #e5e5e7;
  --border-subtle: #e4e4e7;
  --border-focus: #a1a1aa;
  --text-main: #000000;
  --text-muted: #666666;
  --text-subtle: #999999;
  
  /* Semantic Chart Colors */
  --chart-green: #16a34a;
  --chart-green-dim: rgba(22, 163, 74, 0.14);
  --chart-yellow: #ca8a04;
  --chart-yellow-dim: rgba(202, 138, 4, 0.14);
  --chart-red: #dc2626;
  --chart-red-dim: rgba(220, 38, 38, 0.14);
  --chart-gray: #71717a;

  /* Categorical series, in fixed order (reference palette, light steps) */
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --viz-3: #1baf7a;
  --viz-4: #eda100;
  --viz-5: #e87ba4;
  --viz-6: #008300;
  --viz-7: #6250d6;
  --viz-8: #e34948;
}

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: 'tnum', 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Minimalist Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  margin: 1.25rem 0 1.25rem 0;
  transition: border-color 0.2s ease;
}
.app-header:hover {
  border-color: var(--border-focus);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--text-main);
}
.brand-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  display: flex;
  gap: 0.6rem;
}

/* Top-level Navigation Tabs */
.main-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
}
.main-nav .nav-end {
  margin-left: auto;
}

/* Phones: the tabs scroll sideways rather than wrap, and the brand gives way to the tabs */
@media (max-width: 720px) {
  .main-nav {
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0.1rem;
  }
  .main-nav::-webkit-scrollbar {
    display: none;
  }
  .main-nav > * {
    flex-shrink: 0;
  }
  .main-nav .nav-brand {
    display: none;
  }
}

.main-nav-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-muted);
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: -1px;
  transition: color 0.18s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.main-nav-btn:hover {
  color: var(--text-main);
  background: transparent;
}
.main-nav-btn.active {
  color: var(--text-main);
  border-bottom-color: var(--text-main);
  background: transparent;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.65rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid;
}
.status-active {
  background: var(--chart-green-dim);
  color: var(--chart-green);
  border-color: var(--chart-green);
}
.status-offline {
  background: var(--chart-red-dim);
  color: var(--chart-red);
  border-color: var(--chart-red);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Metric Cards */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: default;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.2s ease,
              box-shadow 0.2s ease;
}
.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.metric-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}
.metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
}
.metric-unit {
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  color: var(--text-subtle);
}
.metric-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  margin: 0.25rem 0;
}
.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.metric-sparkline {
  width: 100%;
  height: 32px;
  margin-top: 0.5rem;
  overflow: visible;
}

/* Dashboard section heading with its window buttons; the buttons wrap under the title on a narrow screen */
.dash-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0 0.75rem 0;
}

/* Minimalist Graphs Grid */
.charts-grid {
  display: grid;
  /* Never wider than the screen, so a phone gets one full-width column */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.chart-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.2s ease;
}
.chart-panel:hover {
  border-color: var(--border-focus);
}
.chart-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.chart-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
}
.chart-legend {
  display: flex;
  gap: 0.85rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.legend-line {
  width: 12px;
  height: 2px;
}

.svg-chart-container {
  position: relative;
  width: 100%;
  height: 160px;
}
.svg-chart {
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  top: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-focus);
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  color: var(--text-main);
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 10;
  white-space: nowrap;
}

/* Action Buttons */
button, [role="button"] {
  border-radius: 4px !important;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
  padding: 0.45rem 0.9rem !important;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}
button:hover, [role="button"]:hover {
  transform: translateY(-1px);
}
button:active, [role="button"]:active {
  transform: translateY(1px);
}

button.btn-primary {
  background: var(--text-main) !important;
  color: var(--bg-base) !important;
  border: 1px solid var(--text-main) !important;
}
button.btn-secondary {
  background: transparent !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-subtle) !important;
}
button.btn-secondary:hover {
  border-color: var(--border-focus) !important;
  background: var(--bg-surface-hover) !important;
}

/* Badges */
.badge-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  border: 1px solid;
  display: inline-block;
}
.badge-hot {
  background: var(--chart-green-dim);
  color: var(--chart-green);
  border-color: var(--chart-green);
}
.badge-restart {
  background: var(--chart-yellow-dim);
  color: var(--chart-yellow);
  border-color: var(--chart-yellow);
}

/* ==================== SETTINGS LAYOUT ==================== */
.settings-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 1.75rem;
  align-items: start;
}
.settings-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 1rem;
}
.sidebar-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.4rem 0.6rem 0.25rem 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.sidebar-heading:hover {
  color: var(--text-main);
}
.sidebar-arrow {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}
.sidebar-arrow.open {
  transform: rotate(180deg);
}
.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.sidebar-btn {
  text-align: left !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  border: none !important;
  border-radius: 4px !important;
  padding: 0.45rem 0.7rem !important;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  margin: 0 !important;
  width: 100% !important;
  display: block !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}
.sidebar-btn:hover {
  color: var(--text-main) !important;
  background: var(--bg-surface-hover) !important;
}
.sidebar-btn.active {
  color: var(--text-main) !important;
  background: var(--bg-surface-elevated) !important;
  font-weight: 700 !important;
  box-shadow: inset 2px 0 0 var(--text-main);
}
.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.75rem 0.4rem;
}
.sidebar-back {
  margin-bottom: 0.25rem !important;
}

/* Control Center overview: one group of tiles per heading, each tile a link to a settings page */
.settings-home-group {
  margin-bottom: 1.5rem;
}
.settings-home-heading {
  padding-left: 0.1rem;
  margin-bottom: 0.4rem;
}
.settings-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.75rem;
}
.settings-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 2.25rem 1rem 1.1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.settings-tile:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-focus);
  color: var(--text-main);
}
.settings-tile-title {
  font-size: 0.9rem;
  font-weight: 600;
}
.settings-tile-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.settings-tile-arrow {
  position: absolute;
  top: 0.95rem;
  right: 1rem;
  color: var(--text-subtle);
  transition: transform 0.15s ease, color 0.15s ease;
}
.settings-tile:hover .settings-tile-arrow {
  color: var(--text-main);
  transform: translateX(3px);
}

/* Config rows: description on the left (30%), control on the right (70%) */
.setting-grid {
  /* Label 30%, input 60%, needs-restart 10%. Labels sit left; inputs and badges sit right. */
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 6fr) minmax(0, 1fr);
  gap: 0.6rem 1.25rem;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-grid:last-child {
  border-bottom: none;
}
/* Rows without a restart column let their control take the whole right side */
.setting-grid:not(:has(> .setting-restart)) > .setting-control {
  grid-column: 2 / 4;
}
.setting-control {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
}
.setting-control {
  /* Pico form spacing for the inputs in this column: compact, not the full-size default */
  --form-element-spacing-vertical: 0.3rem;
  --form-element-spacing-horizontal: 0.6rem;
}
.setting-control .setting-input,
.setting-control select {
  flex: 1 1 220px;
  min-width: 0;
  max-width: none;
  margin-bottom: 0;
  padding-top: 0.3rem !important;
  padding-bottom: 0.3rem !important;
  padding-left: 0.6rem !important;
  line-height: 1.4;
}
.setting-restart {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}
.setting-restart .badge-tag {
  white-space: normal;
  text-align: center;
}
.setting-meta {
  font-size: 0.72rem;
  color: var(--text-subtle);
  line-height: 1.5;
  margin-top: 0.3rem;
}
.setting-subhead {
  padding: 0.85rem 0 0.35rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.file-header-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.file-header-summary {
  font-size: 0.82rem;
  color: var(--text-main);
  margin-top: 0.2rem;
}
.file-header-description {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 0.25rem;
  white-space: pre-line;
}

@media (max-width: 720px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
  /* The page list becomes one row of links that scrolls sideways, so the page's own content starts near the top */
  .settings-sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0.4rem;
    gap: 0.2rem;
  }
  .settings-sidebar::-webkit-scrollbar {
    display: none;
  }
  .settings-sidebar > * {
    flex-shrink: 0;
  }
  .settings-sidebar > div {
    display: flex;
    align-items: center;
    gap: 0.2rem;
  }
  .settings-sidebar .sidebar-heading,
  .settings-sidebar .sidebar-divider {
    display: none;
  }
  .settings-sidebar .sidebar-nav-group {
    flex-direction: row;
    gap: 0.2rem;
  }
  .settings-sidebar .sidebar-btn {
    width: auto !important;
    white-space: nowrap;
  }
  .settings-sidebar .sidebar-btn.active {
    box-shadow: inset 0 -2px 0 var(--text-main);
  }
  .console-card {
    flex-wrap: wrap;
  }
  .setting-grid {
    grid-template-columns: 1fr;
  }
  .setting-grid > .setting-control {
    grid-column: auto;
    justify-content: flex-start;
  }
}

/* Service cards: one per managed unit, in a grid */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
  text-align: left;
}
.services-grid .service-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 150px;
  /* Overrides the global button rule, which uses !important for its own padding and radius */
  padding: 16px !important;
  border-radius: 14px !important;
  text-align: left;
  background: linear-gradient(165deg, var(--bg-surface) 0%, color-mix(in srgb, var(--bg-surface) 85%, transparent) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 6px 18px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.service-card:hover,
.service-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--text-muted);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 28px rgba(0, 0, 0, 0.28);
  outline: none;
}
.service-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.service-name {
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--text-main);
}
/* A small dot for the unit's state, on the right of the card. Running units pulse. */
.service-dot {
  position: relative;
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: #6b7280;
}
.service-dot.is-running {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}
.service-dot.is-running::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #22c55e;
  animation: service-pulse 1.8s ease-out infinite;
}
.service-dot.is-warning {
  background: #f59e0b;
}
.service-dot.is-failed {
  background: #ef4444;
}
@keyframes service-pulse {
  0% { transform: scale(1); opacity: 0.75; }
  100% { transform: scale(3.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .service-dot.is-running::after { animation: none; }
}
.service-unit {
  font-family: var(--ev-mono, monospace);
  font-size: 0.74rem;
  color: var(--text-subtle);
}
.service-uptime {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.service-uptime-value {
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}
.service-uptime.is-empty {
  font-size: 0.9rem;
}
.service-table {
  width: 100%;
  border-collapse: collapse;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
}
.service-table th,
.service-table td {
  padding: 0.75rem 0.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
}
.service-table th {
  width: 7.5rem;
  color: var(--text-muted);
}
/* The framework styles table headers and striped rows; the flyout table is plain */
.service-flyout-body .service-table th,
.service-flyout-body .service-table td,
.service-flyout-body .service-table tbody tr:nth-child(odd) th,
.service-flyout-body .service-table tbody tr:nth-child(odd) td {
  background-color: transparent !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-weight: 400 !important;
}
.service-table tr:first-child th,
.service-table tr:first-child td {
  border-top: 1px solid var(--border-subtle);
}
.service-flyout-body {
  display: flex;
  flex-direction: column;
  text-align: left;
}
.service-logs-section {
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding-top: 1rem;
  min-height: 0;
}
/* Grows to the bottom of the flyout only while the logs are open */
.service-logs-section.is-open {
  flex: 1;
}
.service-logs-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.1rem;
}
.service-logs-head .setting-title {
  margin: 0;
}
.service-logs-head .setting-meta {
  flex: 1;
}
.service-logs-head button {
  margin: 0;
}
.service-logs {
  flex: 1;
  min-height: 260px;
  margin-top: 0.5rem;
  overflow: auto;
  text-align: left;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  font-family: var(--ev-mono, monospace);
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.service-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}
.service-boot-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.85rem;
  cursor: pointer;
}
.service-boot-toggle input {
  margin: 0;
}
.service-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
}
.service-actions button {
  margin: 0;
  width: auto;
}

/* Single-Field Setting Rows */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.section-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-row {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-row:first-of-type {
  padding-top: 0.25rem;
}
.setting-row:last-of-type {
  border-bottom: none;
  padding-bottom: 0.25rem;
}
.setting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}
.setting-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
}
.setting-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.65rem;
  max-width: 640px;
}
.setting-input {
  max-width: 480px;
  width: 100%;
}

/* Custom Dropdown Styling (100% Reliable DOM Elements, Zero Native Popup Bugs) */
.custom-select {
  position: relative;
  width: 100%;
  max-width: 480px;
  user-select: none;
}
.custom-select-trigger {
  width: 100% !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  background: var(--bg-base) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 4px !important;
  padding: 0.55rem 0.85rem !important;
  font-size: 0.84rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  text-align: left !important;
  min-height: 2.35rem !important;
  margin: 0 !important;
  transition: border-color 0.15s ease, background-color 0.15s ease !important;
}
.custom-select-trigger:hover {
  border-color: var(--border-focus) !important;
  background: var(--bg-surface-hover) !important;
}
.custom-select-trigger.active {
  border-color: var(--text-main) !important;
  outline: none !important;
}
.custom-select-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  margin-left: 0.5rem;
}
.custom-select-arrow.open {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-focus);
  border-radius: 4px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.25rem;
}
.custom-select-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text-main);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.custom-select-item:hover {
  background: var(--bg-surface-hover);
}
.custom-select-item.selected {
  font-weight: 700;
  background: var(--bg-surface-hover);
}
.custom-select-check {
  color: var(--chart-green);
  font-size: 0.85rem;
  font-weight: 700;
}

/* Fallback / Native Inputs */
input[type="text"], input[type="number"], input[type="file"], input[type="url"], input[type="password"] {
  background: var(--bg-base) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-main) !important;
  border-radius: 4px !important;
  font-size: 0.85rem !important;
  padding: 0.5rem 0.75rem !important;
}
input:focus {
  border-color: var(--border-focus) !important;
  outline: none !important;
}
/* The browser fills saved logins with its own tint; keep the page's input colour instead */
input[type="text"]:-webkit-autofill, input[type="url"]:-webkit-autofill, input[type="password"]:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-base) inset !important;
  -webkit-text-fill-color: var(--text-main) !important;
  caret-color: var(--text-main);
}

textarea.code-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  tab-size: 2;
  min-height: 540px;
  background: var(--bg-base);
  color: var(--text-main);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  padding: 0.85rem;
  width: 100%;
}

.badge-idle {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

/* Protocol Cards */
.protocol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.protocol-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.2s ease;
}
.protocol-card:hover {
  border-color: var(--border-focus);
}
.protocol-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.protocol-count {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}
.protocol-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.protocol-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  color: var(--text-muted);
}
.protocol-stats strong {
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}
.protocol-fingerprint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.7rem;
  color: var(--text-subtle);
}

/* Tables */
.table-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
table {
  margin-bottom: 0 !important;
  font-size: 0.82rem;
}
table th {
  background: var(--bg-surface-elevated);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.6rem 0.85rem;
}
table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}
table tbody tr:hover td {
  background: var(--bg-surface-hover);
}

/* Floating Toast Alerts */
.toast-box {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}
.toast-item {
  padding: 0.65rem 1rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid;
  background: var(--bg-surface-elevated);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast-success {
  border-color: var(--chart-green);
  color: var(--chart-green);
}
.toast-error {
  border-color: var(--chart-red);
  color: var(--chart-red);
}

.pill-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
  transition: all 0.15s ease;
}
.pill-btn:hover {
  color: var(--text-main);
  border-color: var(--border-focus);
}
.pill-btn.active {
  color: var(--text-main);
  border-color: var(--text-main);
  background: var(--bg-surface-elevated);
}

/* Full-width layout: the console uses the whole browser width */
main.container {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Raw YAML editor: highlighted copy behind a transparent textarea */
.yaml-editor {
  position: relative;
  display: grid;
}

.yaml-highlight,
.yaml-input {
  grid-area: 1 / 1;
  margin: 0;
  padding: 0.75rem 0.9rem;
  box-sizing: border-box;
  font-family: var(--ev-mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 0.8rem;
  line-height: 1.55;
  letter-spacing: normal;
  tab-size: 2;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  border: 1px solid var(--border-subtle, #222);
  border-radius: 4px;
  min-height: 24rem;
}

.yaml-highlight {
  overflow: hidden;
  background: var(--bg-surface, #0a0a0a);
  color: var(--text-main, #e5e5e5);
  pointer-events: none;
}

.yaml-input {
  background: transparent;
  color: transparent;
  caret-color: var(--text-main, #e5e5e5);
  resize: vertical;
  outline: none;
  width: 100%;
}

.yaml-input:focus {
  border-color: var(--border-focus, #444);
}

.yaml-highlight .yl-comment {
  color: var(--text-subtle, #555);
  font-style: italic;
}

.yaml-highlight .yl-key {
  color: #93c5fd;
}

/* Buttons: short colour transitions, and a hover delay so brushing past a button does not flash it */
button {
  transition-property: background-color, border-color, color, box-shadow, transform, opacity;
  transition-duration: 0.18s;
  transition-timing-function: ease;
}

button:hover:not(:disabled) {
  transition-delay: 0.09s;
}

/* Top nav: the active tab is yellow with no underline; grey when idle, white on hover */
.main-nav-btn {
  color: var(--text-muted, #888888) !important;
  border-bottom-color: transparent !important;
  text-decoration: none !important;
}

.main-nav-btn.active {
  color: #f59e0b !important;
  border-bottom-color: transparent !important;
  text-decoration: none !important;
}

.main-nav-btn:hover {
  color: #ffffff !important;
}

/* Every top-nav tab shares one side padding, so the gaps between labels match. The global button rule uses !important, so this must too. */
.main-nav-btn {
  padding-left: 0.4rem !important;
  padding-right: 0.4rem !important;
  font-size: 0.7rem !important;
}

/* Health and Control Center are icon-only: outline glyphs in the tab colour, centred in the same box as the text tabs */
.main-nav-btn.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.nav-icon {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Page bottom: Pico adds block spacing below <main> and under each section. Only one section is visible, so the spacing under it is removed. */
main.container {
  padding-bottom: 0.5rem;
}

main.container section {
  margin-bottom: 0;
}

/* ==================== COLLECTIONS (lists and maps as tables) ==================== */
.collection {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.collection-title {
  margin-bottom: 0.6rem;
}
.collection-scroll {
  overflow-x: auto;
}
.collection-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.collection-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  /* Same vertical rhythm as the settings rows (0.85rem) */
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.collection-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  min-width: 8rem;
}
.collection-table .setting-input {
  max-width: none;
  min-width: 7rem;
  width: 100%;
}
.collection-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-main);
  white-space: nowrap;
}
.collection-readonly {
  color: var(--text-main);
  word-break: break-word;
}
.collection-actions {
  white-space: nowrap;
  text-align: right;
  min-width: 0 !important;
}
.collection-actions button {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  margin: 0 0 0 0.3rem;
}
.collection-actions button:disabled {
  opacity: 0.4;
  cursor: default;
}
.collection-add {
  margin-top: 0.6rem;
}
.collection-add-map {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.collection-add-map .setting-input {
  flex: 1 1 200px;
  max-width: 320px;
}

/* Side panel for one entry of a collection in panel view */
.item-panel-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
}
.item-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  overflow-y: auto;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  padding: 1rem 1.15rem;
  z-index: 50;
}
.item-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.item-panel .setting-grid {
  grid-template-columns: 1fr;
  gap: 0.4rem;
}
.item-panel .setting-grid > .setting-control {
  grid-column: auto;
  justify-content: flex-start;
}

/* Drag handle and drop targets for reordering list entries */
.collection-handle,
.collection-handle-head {
  width: 2rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
.drag-handle {
  display: inline-block;
  cursor: grab;
  color: var(--text-subtle);
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.25rem 0.2rem;
  border-radius: 3px;
  user-select: none;
}
.drag-handle {
  background: transparent;
  border: none;
  box-shadow: none;
}
.drag-handle:hover,
.drag-handle:focus-visible {
  color: var(--text-main);
  background: transparent;
  outline: 1px solid var(--border-focus);
}
.drag-handle:active {
  cursor: grabbing;
}
.collection-table tr.dragging td {
  opacity: 0.4;
}
.collection-table tr.drop-before td {
  box-shadow: inset 0 2px 0 var(--border-focus);
}
.collection-table tr.drop-after td {
  box-shadow: inset 0 -2px 0 var(--border-focus);
}
.collection-table tr.drop-end td {
  height: 1.6rem;
  padding: 0.2rem 0.5rem;
  border: 1px dashed var(--border-subtle);
  color: var(--text-subtle);
  font-size: 0.7rem;
  text-align: center;
  background: transparent;
}
.collection-table tr.drop-end.active td {
  border-color: var(--border-focus);
  color: var(--text-main);
  box-shadow: inset 0 2px 0 var(--border-focus);
}

/* Controls inside collection tables sit flush with their cell */
.collection-table input,
.collection-table select {
  margin: 0 !important;
}

/* Column descriptions, footer inputs and key editing */
.collection-col-help {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.66rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-subtle);
  white-space: normal;
  line-height: 1.35;
  max-width: 16rem;
}
.collection-cell-input {
  width: 100%;
  min-width: 6rem;
  margin: 0 !important;
  padding: 0.25rem 0.5rem !important;
  font-size: 0.78rem !important;
  line-height: 1.4;
  background: var(--bg-base) !important;
}
.collection-key-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  min-width: 5rem;
}
.collection-footer td {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  border-bottom: none;
  vertical-align: middle;
}
.collection-footer .collection-actions button {
  margin: 0 !important;
  padding: 0.2rem 0.6rem;
}
.collection-table .collection-actions-head {
  width: 1%;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.collection-actions-head button {
  margin: 0 !important;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem !important;
  text-transform: none;
}

/* Minimal drag handle: a muted grip that brightens on hover */
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--text-subtle);
  opacity: 0.45;
  cursor: grab;
  border-radius: 4px;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.drag-handle svg {
  width: 0.6rem;
  height: 0.9rem;
  fill: currentColor;
}
.drag-handle:hover,
.drag-handle:focus-visible {
  opacity: 1;
  color: var(--text-main);
  background: transparent;
  outline: none;
}
.drag-handle:focus-visible {
  box-shadow: 0 0 0 1px var(--border-focus);
}
.drag-handle:active {
  cursor: grabbing;
}

/* Drop indicator: a thin accent line between rows */
.collection-table tr.drop-before td,
.collection-table tr.drop-after td {
  position: relative;
}
.collection-table tr.drop-before td::before,
.collection-table tr.drop-after td::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--border-focus);
  pointer-events: none;
}
.collection-table tr.drop-before td::before {
  top: -1px;
}
.collection-table tr.drop-after td::after {
  bottom: -1px;
}
.collection-table tr.dragging td {
  opacity: 0.35;
}
.collection-table tr.drop-end td {
  height: 0.5rem;
  padding: 0;
  border: none;
}
.collection-table tr.drop-end.active td {
  position: relative;
}
.collection-table tr.drop-end.active td::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--border-focus);
}

.collection-key-text {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Map tables have no drag handle, so the key column gets the left inset */
.collection-table .collection-key-head,
.collection-table .collection-key {
  padding-left: 0.75rem;
}

/* Interface overlay and database analytics */
.iface-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-top: 0.75rem;
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  color: var(--text-muted);
}
.iface-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.iface-stat strong {
  color: var(--text-main);
  font-weight: 600;
}
.iface-swatch {
  width: 10px;
  height: 2px;
  border-radius: 1px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 1180px) {
  .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .analytics-grid { grid-template-columns: minmax(0, 1fr); }
}
.analytics-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.analytics-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-subtle);
  margin-top: 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}
.analytics-error {
  color: var(--chart-red);
  font-size: 0.8rem;
  margin-bottom: 1rem;
}
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 40%) 1fr auto;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
}
.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}
.bar-track {
  height: 10px;
  background: var(--bg-surface-elevated);
  border-radius: 0 4px 4px 0;
}
.bar-fill {
  height: 100%;
  background: var(--viz-1);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.bar-value {
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}
.analytics-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 2rem 0;
  text-align: center;
}

[x-cloak] { display: none !important; }

/* Expand button: revealed on hover or keyboard focus; always shown where there is no hover */
.expand-btn {
  width: 1.9rem !important;
  height: 1.9rem;
  padding: 0 !important;
  line-height: 1;
  font-size: 1rem !important;
  background: transparent !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-muted) !important;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.chart-panel:hover .expand-btn,
.expand-btn:focus-visible {
  opacity: 1;
}
.expand-btn:hover {
  color: var(--text-main) !important;
  border-color: var(--border-focus) !important;
}
@media (hover: none) {
  .expand-btn { opacity: 1; }
}

/* Chart page */
.chart-page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}
.window-picker {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.picker-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}
.chart-page-actions {
  display: flex;
  gap: 0.35rem;
}
.chart-page-block {
  margin-top: 1.25rem;
}
.chart-page-heading {
  font-size: 0.75rem !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.6rem 0 !important;
}
.chart-page-chart {
  height: 300px;
}
.chart-page-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
.chart-page-card {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  background: var(--bg-surface-elevated);
}
.chart-page-card-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-page-card-value {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.2rem;
  word-break: break-word;
}
.chart-page-about dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(150px, 210px) 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.82rem;
}
.chart-page-about dt {
  color: var(--text-muted);
  font-weight: 600;
}
.chart-page-about dd {
  margin: 0;
  line-height: 1.5;
}
@media (max-width: 640px) {
  .chart-page-about dl { grid-template-columns: 1fr; }
  .chart-page-about dt { margin-top: 0.5rem; }
}

/* Tables of the maximised view */
.chart-table-wrap {
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}
.chart-table-short {
  max-height: none;
}
.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}
.chart-table th,
.chart-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.chart-table td:last-child,
.chart-table th:last-child {
  word-break: normal;
}
.chart-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-surface-elevated);
  font-weight: 600;
  color: var(--text-muted);
}
.sort-btn {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  color: inherit !important;
  font: inherit !important;
  cursor: pointer;
}
.chart-page-about .analytics-note {
  margin-top: 0.75rem;
}

.chart-page {
  width: 100%;
  margin-top: 0.5rem;
}
.chart-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.25rem;
}
.chart-page-title {
  font-size: 1.15rem !important;
  margin: 0 0 0.3rem 0 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chart-page-summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* The data table of a chart page shows every row; only the page scrolls */
.chart-table-full {
  max-height: none;
  overflow: visible;
  overflow-x: auto;
}

/* Assets and Services Directory: tab row and the header of each tab's card */
.registry-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 1rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

/* Health page: the section tabs on the left, the time range on the right, on one line */
.health-tab-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin: 0 0 1rem;
}

.health-tabs {
  margin: 0;
  border-bottom: none;
}

/* The global button rule sets these with !important; the tabs are links, so they set them here */
.health-tabs a.registry-tab {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
}

.health-range {
  display: flex;
  gap: 0.5rem;
  padding-bottom: 0.4rem;
}

button.registry-tab,
a.registry-tab {
  margin: 0;
  text-decoration: none;
  padding: 0.55rem 0;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
}

button.registry-tab:hover,
a.registry-tab:hover {
  color: var(--text-main);
}

button.registry-tab.active,
a.registry-tab.active {
  color: var(--text-main);
  border-bottom-color: var(--ev-accent, #f59e0b);
}


/* Partitions of a table as bars: the label, a bar for the rows, the row count and the stored size */
.partition-chart {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.25rem 0 0.5rem;
}

.partition-row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) 6rem 7rem 7rem 7rem 6rem 6rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
}

/* Column names above the partition rows, in the same style as the table headers */
.partition-head {
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--ev-rule, var(--border-subtle));
  color: var(--text-muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.partition-label {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-muted);
}

.partition-track {
  height: 0.6rem;
  background: var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
}

.partition-bar {
  display: block;
  height: 100%;
  background: var(--chart-green);
  border-radius: 3px;
}

.partition-rows {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.partition-stored {
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Partitions with no rows are muted, so the days that hold data stand out */
.partition-row.is-empty {
  opacity: 0.4;
}

/* Total row under the partitions: sums the rows and sizes, set off by a rule above */
.partition-row.partition-total {
  margin-top: 0.3rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--ev-rule, var(--border-subtle));
  color: var(--text-main);
  font-weight: 600;
}

/* Filesystem tab: the disk card has its figures at the top left and its graph across the whole card */
.fs-disk-card {
  margin-bottom: 0.5rem;
}

.fs-disk-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.fs-disk-card .health-line {
  display: block;
  width: 100%;
  height: 6rem;
  margin: 0.75rem 0 0.4rem;
}

/* Probe directories: one bar from 0 to the highest size over the window, in three tints of the chart
   green: 0 to the lowest size, lowest to current, and current to highest. The lowest and highest sizes
   are labelled inside the bar. */
/* Fixed column widths, so the range bar gets the room the name and path columns give up */
.dir-table {
  table-layout: fixed;
}

.dir-table th:nth-child(1),
.dir-table td:nth-child(1) {
  width: 16%;
}

.dir-table th:nth-child(2),
.dir-table td:nth-child(2) {
  width: 26%;
}

.dir-table th:nth-child(3),
.dir-table td:nth-child(3) {
  width: 46%;
}

.dir-table th:nth-child(4),
.dir-table td:nth-child(4) {
  width: 12%;
}

.dir-size {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dir-range {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dir-range-track {
  position: relative;
  display: block;
  height: 1.25rem;
  border-radius: 6px;
  background: var(--border-subtle);
}

.dir-range-segs {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  border-radius: inherit;
}

.dir-range-seg {
  height: 100%;
}

.dir-range-seg-floor {
  background: var(--chart-green);
  opacity: 0.85;
}

.dir-range-seg-rise {
  background: var(--chart-green);
  opacity: 0.5;
}

.dir-range-seg-headroom {
  background: var(--chart-green);
  opacity: 0.2;
}

.dir-range-label {
  position: absolute;
  top: 0;
  line-height: 1.25rem;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  color: var(--text-main);
  text-shadow: 0 0 3px var(--bg-surface);
}

/* The minimum sits at the bar's left end, the maximum at its right end */
.dir-range-label-min {
  left: 0;
}

.dir-range-label-max {
  right: 0;
}

.dir-name {
  text-transform: uppercase;
}

.dir-path {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Database header graph: Low and High on the left of the foot line, the table split on the right.
   The foot is one line, like the filesystem graph's, so the two cards are the same height. */
.db-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.db-breakdown {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem 1rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.db-breakdown-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.services-figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.fs-graph-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 1100px) {
  .fs-graph-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .fs-disk-body {
    flex-direction: column;
  }
  .fs-disk-graph {
    max-width: none;
  }
}

.tab-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.tab-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.tab-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Tab row: the tabs sit left, Services on the far right. Pico spreads nav items, so reset it. */
.registry-tabs {
  justify-content: flex-start;
}

/* Count of unsaved changes beside a tab name */
.tab-count {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--ev-accent, #f59e0b);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
  letter-spacing: 0;
}

/* Changed or drafted rows: amber, so they stand out from saved entries */
tr.is-changed td {
  background: rgba(245, 158, 11, 0.14) !important;
}

tr.is-changed td:first-child {
  box-shadow: inset 3px 0 0 var(--ev-accent, #f59e0b);
}

.draft-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--ev-accent, #f59e0b);
  border-radius: 3px;
  color: var(--ev-accent, #f59e0b);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.draft-note {
  color: var(--ev-accent, #f59e0b);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* The shared asset editor: amber edge, so it reads as a draft in progress */
.editor-card {
  border-left: 3px solid var(--ev-accent, #f59e0b);
}

/* Randomised (locally administered) MAC addresses, marked with a * */
.mac-random {
  color: var(--ev-accent, #f59e0b);
  font-weight: 700;
}

/* Banner of a service on the Service Radar: one line, full text on hover */
.banner-cell {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--ev-mono, monospace);
  font-size: 0.75rem;
}

/* Name suggested from a banner or a well-known port */
.suggest-note {
  margin-left: 0.4rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Health page: gauge lines fill their card */
.health-line {
  display: block;
  width: 100%;
  height: 80px;
}

/* Storage on the health page: one bar per day, relative to the largest day */
.health-bar {
  height: 6px;
  width: 100%;
  background: var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.health-bar span {
  display: block;
  height: 100%;
  background: var(--chart-green);
}

/* Shown after the version when the probe and the console were built from different versions */
.version-warn {
  margin-left: 0.2em;
  font-weight: 700;
  color: var(--chart-yellow);
  cursor: help;
}

/* Live figures under a service card on the Settings page, in the muted style of its other lines */
.service-live {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
