/**
 * Theme
 */
:root {
  color-scheme: light;
  --font: 'Segoe UI Variable Text', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Cascadia Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f5;
  --border: #e1e5eb;
  --border-strong: #c9d0da;
  --text: #1b2330;
  --text-muted: #5d6878;
  --accent: #0f6cbd;
  --accent-strong: #0c5a9e;
  --accent-soft: #e6f0fa;
  --success: #0e7a3b;
  --success-soft: #e3f4e9;
  --warning: #a65c00;
  --warning-soft: #fdf1df;
  --danger: #c22b2b;
  --danger-soft: #fbe7e7;
  --info: #2364c2;
  --info-soft: #e5eefb;
  --neutral: #5d6878;
  --neutral-soft: #eceff3;
  --purple: #7442c8;
  --purple-soft: #f0e9fb;
  --status-online: #16a34a;
  --status-degraded: #f59e0b;
  --status-unhealthy: #dc2626;
  --status-turning-on: #0ea5e9;
  --status-turning-off: #a855f7;
  --status-offline: #64748b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  --radius-small: 6px;
  --topbar-height: 56px;
  --sidebar-width: 272px;
  --ribbon-height: 0px;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f131a;
  --surface: #171c25;
  --surface-2: #1c222d;
  --surface-3: #232a36;
  --border: #2a3240;
  --border-strong: #3a4455;
  --text: #e6eaf0;
  --text-muted: #9aa5b5;
  --accent: #4da3ff;
  --accent-strong: #79b9ff;
  --accent-soft: #15283f;
  --success: #4ade80;
  --success-soft: #12301f;
  --warning: #fbbf24;
  --warning-soft: #352710;
  --danger: #f87171;
  --danger-soft: #3a1717;
  --info: #60a5fa;
  --info-soft: #14253d;
  --neutral: #9aa5b5;
  --neutral-soft: #252c38;
  --purple: #b794f6;
  --purple-soft: #2a1f40;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/**
 * Base
 */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  font-weight: 650;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
}

p {
  margin: 0.4rem 0;
}

code, pre, kbd, .code-input, .diff-table {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

code {
  background: var(--surface-3);
  color: var(--code-text, inherit);
  border-radius: 4px;
  overflow-wrap: anywhere;
  padding: 0.05em 0.35em;
}

pre code {
  background: none;
  padding: 0;
}

button {
  color: inherit;
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.82rem;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.wrap {
  flex-wrap: wrap;
}

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/**
 * Icons
 */
.icon {
  background-color: currentColor;
  display: inline-block;
  flex: none;
  height: 1em;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  vertical-align: -0.125em;
  width: 1em;
}

/**
 * Tones
 */
.tone-success { --tone: var(--success); --tone-soft: var(--success-soft); }
.tone-warning { --tone: var(--warning); --tone-soft: var(--warning-soft); }
.tone-danger { --tone: var(--danger); --tone-soft: var(--danger-soft); }
.tone-info { --tone: var(--info); --tone-soft: var(--info-soft); }
.tone-neutral { --tone: var(--neutral); --tone-soft: var(--neutral-soft); }
.tone-accent { --tone: var(--purple); --tone-soft: var(--purple-soft); }
.tone-text-success { color: var(--success); }
.tone-text-warning { color: var(--warning); }
.tone-text-danger { color: var(--danger); }

.status-online { --status: var(--status-online); }
.status-degraded { --status: var(--status-degraded); }
.status-unhealthy { --status: var(--status-unhealthy); }
.status-turning-on { --status: var(--status-turning-on); }
.status-turning-off { --status: var(--status-turning-off); }
.status-offline { --status: var(--status-offline); }

/**
 * Shell
 */
.shell {
  display: grid;
  grid-template-areas: 'ribbon ribbon' 'topbar topbar' 'sidebar content';
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: auto var(--topbar-height) 1fr;
  min-height: 100vh;
}

.environment-ribbon {
  background: var(--tone, var(--warning));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  grid-area: ribbon;
  letter-spacing: 0.04em;
  height: var(--ribbon-height);
  line-height: var(--ribbon-height);
  overflow: hidden;
  padding: 0 12px;
  position: sticky;
  text-align: center;
  text-overflow: ellipsis;
  top: 0;
  white-space: nowrap;
  z-index: 31;
}

.shell:has(> .environment-ribbon) {
  --ribbon-height: 20px;
}

[data-theme='dark'] .environment-ribbon {
  color: #10141b;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  grid-area: topbar;
  padding: 0 12px;
  position: sticky;
  top: var(--ribbon-height);
  z-index: 30;
}

.topbar-menu {
  display: none;
}

.brand {
  align-items: center;
  color: var(--text);
  display: flex;
  font-size: 1.05rem;
  font-weight: 650;
  gap: 10px;
  margin-right: 4px;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.topbar-spacer {
  flex: 1 1 auto;
}

.sidebar {
  align-self: start;
  background: var(--surface);
  border-right: 1px solid var(--border);
  grid-area: sidebar;
  height: calc(100vh - var(--topbar-height) - var(--ribbon-height));
  overflow-y: auto;
  position: sticky;
  top: calc(var(--topbar-height) + var(--ribbon-height));
}

.sidebar-backdrop {
  display: none;
}

.content {
  grid-area: content;
  margin: 0 auto;
  max-width: 1600px;
  min-width: 0;
  padding: 20px 24px 48px;
  width: 100%;
}

.content > * + * {
  margin-top: 16px;
}

@media (max-width: 960px) {
  .shell {
    grid-template-areas: 'ribbon' 'topbar' 'content';
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-menu {
    display: inline-flex;
  }

  .sidebar {
    box-shadow: var(--shadow-lg);
    height: 100vh;
    left: 0;
    position: fixed;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    width: min(86vw, var(--sidebar-width));
    z-index: 50;
  }

  .menu-open .sidebar {
    transform: none;
  }

  .menu-open .sidebar-backdrop {
    background: rgba(10, 14, 20, 0.45);
    display: block;
    inset: 0;
    position: fixed;
    z-index: 40;
  }

  .content {
    padding: 14px 12px 40px;
  }
}

@media (max-width: 600px) {
  .hide-small, .brand-name, .environment-badge {
    display: none !important;
  }

  .topbar {
    gap: 4px;
    padding: 0 6px;
  }

  h1 {
    font-size: 1.25rem;
  }
}

.startup-error {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.startup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 520px;
  padding: 24px;
}

/**
 * Side menu
 */
.menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 100%;
  padding: 12px 10px;
}

.menu-filter {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 10px;
}

.menu-filter input {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1;
  min-width: 0;
  outline: none;
  padding: 8px 0;
}

.menu-group + .menu-group {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 6px;
}

.menu-heading, .menu-section {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 8px 10px 4px;
  text-transform: uppercase;
}

.menu-section {
  padding-left: 34px;
}

.menu-group-toggle {
  align-items: center;
  background: none;
  border: 0;
  border-radius: var(--radius-small);
  cursor: pointer;
  display: flex;
  font-weight: 600;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.menu-group-toggle:hover {
  background: var(--surface-3);
}

.menu-group-title {
  flex: 1;
}

.menu-chevron {
  color: var(--text-muted);
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}

.menu-group.expanded .menu-chevron {
  transform: none;
}

.menu-group-collapsible .menu-link {
  padding-left: 34px;
}

.menu-link {
  align-items: center;
  border-radius: var(--radius-small);
  color: var(--text);
  display: flex;
  gap: 10px;
  padding: 7px 10px;
}

.menu-link .icon {
  color: var(--text-muted);
}

.menu-link:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.menu-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.menu-link.active .icon {
  color: var(--accent);
}

.menu-item {
  align-items: center;
  display: flex;
  position: relative;
}

.menu-item .menu-link {
  flex: 1;
  min-width: 0;
}

.menu-link-title {
  flex-shrink: 0;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-link-source {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 400;
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  padding-left: 0.5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-pin {
  align-items: center;
  background: none;
  border: 0;
  border-radius: var(--radius-small);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  flex: none;
  height: 28px;
  justify-content: center;
  opacity: 0;
  width: 28px;
}

.menu-item:hover .menu-pin, .menu-pin:focus-visible, .menu-pin.pinned {
  opacity: 1;
}

.menu-pin:hover {
  background: var(--surface-3);
  color: var(--text);
}

.menu-pin.pinned {
  color: var(--warning);
}

.menu-group-pinned .menu-pin.pinned {
  opacity: 0;
}

.menu-group-pinned .menu-item:hover .menu-pin.pinned, .menu-group-pinned .menu-pin.pinned:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .menu-pin {
    opacity: 1;
  }
}

.menu-empty {
  padding: 10px;
}

.menu-footer {
  font-size: 0.75rem;
  margin-top: auto;
  padding: 16px 10px 4px;
}

/**
 * Buttons
 */
.button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-weight: 500;
  gap: 6px;
  justify-content: center;
  line-height: 1.2;
  min-height: 34px;
  padding: 6px 12px;
  white-space: nowrap;
}

.button:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.button:disabled, .button-icon:disabled, .dropdown-item:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-accent, .button-success, .button-danger, .button-warning, .button-info {
  border-color: transparent;
  color: #fff;
}

.button-accent { background: var(--accent); }
.button-accent:hover { background: var(--accent-strong); }
.button-success { background: var(--success); }
.button-danger { background: var(--danger); }
.button-warning { background: var(--warning); }
.button-info { background: var(--info); }

[data-theme='dark'] .button-accent, [data-theme='dark'] .button-success, [data-theme='dark'] .button-danger, [data-theme='dark'] .button-warning, [data-theme='dark'] .button-info {
  color: #0f131a;
}

.button-success:hover, .button-danger:hover, .button-warning:hover, .button-info:hover {
  filter: brightness(1.08);
}

.button-neutral {
  background: var(--surface);
}

.button-ghost {
  background: transparent;
  border-color: transparent;
}

.button-small {
  font-size: 0.82rem;
  min-height: 28px;
  padding: 3px 9px;
}

.button-icon {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-small);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  flex: none;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.button-icon:hover {
  background: var(--surface-3);
  color: var(--text);
}

.button-row, .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

/**
 * Dropdowns
 */
.dropdown {
  position: relative;
}

.dropdown-backdrop {
  inset: 0;
  position: fixed;
  z-index: 60;
}

.dropdown-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
  min-width: 250px;
  overflow-y: auto;
  padding: 6px;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 61;
}

.dropdown-right {
  right: 0;
}

.dropdown-header {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 8px 10px 4px;
  text-transform: uppercase;
}

.dropdown-item {
  align-items: center;
  background: none;
  border: 0;
  border-radius: var(--radius-small);
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.dropdown-item:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.dropdown-item.active {
  color: var(--accent);
  font-weight: 600;
}

.dropdown-item-text {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.dropdown-note {
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  margin-top: 6px;
  padding: 8px 10px 4px;
}

.account-toggle {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  padding: 3px;
}

.account-summary {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 8px 10px 10px;
}

.account-summary .badge-row {
  margin-top: 4px;
}

.avatar {
  align-items: center;
  background: var(--accent);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  flex: none;
  font-size: 0.8rem;
  font-weight: 600;
  height: 32px;
  justify-content: center;
  width: 32px;
}

[data-theme='dark'] .avatar {
  color: #0f131a;
}

.avatar-square {
  background: var(--purple-soft);
  border-radius: var(--radius-small);
  color: var(--purple);
  height: 40px;
  width: 40px;
}

.avatar-large {
  font-size: 1.2rem;
  height: 56px;
  width: 56px;
}

/**
 * Page header
 */
.page-header {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.page-heading {
  min-width: 0;
}

.page-heading h1 {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-heading h1 > .icon {
  color: var(--accent);
}

.page-heading h1 > span:not(.icon):not(.badge) {
  overflow-wrap: anywhere;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 4px 0 0;
}

.breadcrumbs {
  color: var(--text-muted);
  display: flex;
  font-size: 0.82rem;
  gap: 6px;
  margin-bottom: 4px;
}

.breadcrumbs > *::after {
  color: var(--text-muted);
  content: '›';
  margin-left: 6px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  align-items: center;
  display: flex;
  gap: 8px;
  margin: 4px 0 10px;
}

* + .section-title {
  margin-top: 20px;
}

.properties + .button-row {
  margin: 16px 0 4px;
}

.icon-leading {
  margin-right: 6px;
}

/**
 * Cards
 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 12px 16px;
}

.card-body {
  padding: 14px 16px;
}

.card-toggle {
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.card-toggle:hover {
  background: var(--surface-2);
}

.card-toggle .icon-chevron {
  color: var(--text-muted);
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}

.card-toggle .icon-chevron.rotated {
  transform: none;
}

.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

.grid-2 + *, * + .grid-2 {
  margin-top: 16px;
}

/**
 * Alerts, loading, empty
 */
.alert {
  align-items: flex-start;
  background: var(--tone-soft, var(--info-soft));
  border: 1px solid color-mix(in srgb, var(--tone, var(--info)) 35%, transparent);
  border-radius: var(--radius);
  display: flex;
  gap: 10px;
  padding: 10px 14px;
}

.alert > .icon {
  color: var(--tone, var(--info));
  margin-top: 3px;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-body ul {
  margin: 0;
  padding-left: 18px;
}

.announcements {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.announcement {
  align-items: center;
}

.announcement > .icon {
  margin-top: 0;
}

.announcement-body {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.announcement-message p {
  margin: 0;
}

.announcement-link {
  align-items: center;
  display: inline-flex;
  font-weight: 600;
  gap: 4px;
  white-space: nowrap;
}

.announcement-dismiss {
  flex: none;
}

.loading {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 32px 16px;
}

.loading-inline {
  display: inline-flex;
  padding: 0;
}

.spinner {
  animation: spin 0.8s linear infinite;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  border-top-color: var(--accent);
  display: inline-block;
  height: 20px;
  width: 20px;
}

.spinner-small {
  height: 14px;
  width: 14px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-state {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 32px 16px;
  text-align: center;
}

.empty-state > .icon {
  font-size: 2rem;
  opacity: 0.6;
}

.empty-state strong {
  color: var(--text);
}

/**
 * Badges and chips
 */
.badge {
  align-items: center;
  background: var(--tone-soft, var(--neutral-soft));
  border-radius: 999px;
  color: var(--tone, var(--neutral));
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 600;
  gap: 5px;
  line-height: 1.3;
  padding: 2px 9px;
  white-space: nowrap;
}

a.badge:hover {
  filter: brightness(0.95);
  text-decoration: none;
}

.badge-dot {
  background: currentColor;
  border-radius: 50%;
  height: 7px;
  width: 7px;
}

.badge-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-button {
  align-items: center;
  background: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  gap: 4px;
  padding: 0;
}

.chip-input {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
}

.chip {
  align-items: center;
  background: var(--info-soft);
  border-radius: 999px;
  color: var(--info);
  display: inline-flex;
  font-size: 0.8rem;
  font-weight: 600;
  gap: 2px;
  padding: 2px 4px 2px 10px;
}

.chip-remove {
  align-items: center;
  background: none;
  border: 0;
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.65rem;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.chip-remove:hover {
  background: color-mix(in srgb, currentColor 18%, transparent);
}

.chip-text {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1;
  min-width: 160px;
  outline: none;
  padding: 4px;
}

.environment-chip {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font-size: 0.8rem;
  gap: 6px;
  padding: 2px 10px;
}

.environment-chip .legend-dot {
  background: var(--status, var(--neutral));
}

/**
 * Forms
 */
.input, select.input, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  color: var(--text);
  font: inherit;
  min-height: 34px;
  padding: 6px 10px;
  width: 100%;
}

select.input {
  width: auto;
}

textarea {
  resize: vertical;
}

.input:focus, textarea:focus, .chip-input:focus-within {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.code-input {
  font-size: 0.85rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 10px 0 5px;
}

.field > .field-label {
  margin: 0;
}

.field-label-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.checkbox {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}

.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-end {
  justify-content: flex-end;
}

.filters {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.filters .filter-wide {
  grid-column: 1 / -1;
}

.filters select.input {
  width: 100%;
}

.search-input {
  align-items: center;
  display: flex;
  position: relative;
}

.search-input > .icon {
  color: var(--text-muted);
  left: 11px;
  pointer-events: none;
  position: absolute;
}

.search-input .input {
  padding-left: 32px;
}

.segmented {
  background: var(--surface-3);
  border-radius: var(--radius-small);
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  padding: 5px 12px;
}

.segmented button.active {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
}

.segmented-small button {
  font-size: 0.78rem;
  padding: 2px 8px;
}

.summary-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

/**
 * Tables
 */
.table-wrapper {
  overflow-x: auto;
}

.data-table {
  border-collapse: collapse;
  width: 100%;
}

.data-table th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 9px 12px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 12px;
  vertical-align: top;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table .numeric {
  text-align: right;
}

.cell-primary {
  font-weight: 600;
}

.cell-wrap {
  max-width: 420px;
  overflow-wrap: anywhere;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.sort-button {
  align-items: center;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 4px;
  letter-spacing: inherit;
  padding: 0;
  text-transform: inherit;
}

.data-table-compact .data-table th,
.data-table-compact .data-table td {
  padding: 6px 8px;
}

.data-table-compact .data-table th:first-child,
.data-table-compact .data-table td:first-child {
  padding-left: 0;
}

.data-table-compact .data-table th:last-child,
.data-table-compact .data-table td:last-child {
  padding-right: 0;
}

.data-table-compact .data-table th {
  background: none;
}

.data-table-compact .table-pager {
  padding-left: 0;
  padding-right: 0;
}

.data-table-frame[aria-busy="true"] .table-wrapper {
  opacity: 0.6;
  transition: opacity 0.2s;
}

.table-pager {
  align-items: center;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 12px;
}

.table-pager-range {
  margin-right: auto;
}

.table-pager-size {
  width: auto;
}

.table-pager-pages {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.table-pager-page {
  min-width: 34px;
}

.table-pager-page.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.table-pager-gap {
  color: var(--text-muted);
  padding: 0 4px;
}

.table-pager-previous {
  transform: rotate(90deg);
}

.table-pager-next {
  transform: rotate(-90deg);
}

.table-pager.is-compact {
  border-bottom: 1px solid var(--border);
  border-top: 0;
}

.table-header {
  align-items: center;
  display: inline-flex;
  gap: 4px;
}

.table-header-filter {
  background: none;
  border: 0;
  border-radius: var(--radius-small);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  opacity: 0.55;
  padding: 2px 3px;
}

.table-header-filter:hover, .table-header-filter:focus-visible {
  background: var(--surface-3);
  opacity: 1;
}

.table-header-filter.is-active {
  color: var(--accent);
  opacity: 1;
}

.table-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.table-toolbar-search {
  flex: 1 1 220px;
  max-width: 360px;
}

.table-toolbar-search .input {
  width: 100%;
}

.table-filter-pill {
  align-items: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.82rem;
  gap: 6px;
  max-width: 320px;
  padding: 5px 10px;
}

.table-filter-pill:hover {
  background: var(--surface-2);
  color: var(--text);
}

.table-filter-pill.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-style: solid;
  color: var(--text);
}

.table-filter-pill.is-active > .icon-funnel {
  color: var(--accent);
}

.table-filter-title {
  font-weight: 600;
  white-space: nowrap;
}

.table-filter-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-filter-caret {
  font-size: 0.7rem;
}

.table-filter-menu {
  max-width: min(340px, calc(100vw - 24px));
  min-width: min(280px, calc(100vw - 24px));
  padding: 12px;
}

.table-filter-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-filter-editor .input {
  width: 100%;
}

.table-filter-bulk {
  display: flex;
  gap: 6px;
}

.table-filter-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
}

.table-filter-option {
  border-radius: var(--radius-small);
  padding: 4px 6px;
  white-space: normal;
}

.table-filter-option:hover {
  background: var(--surface-3);
}

.table-filter-option-text {
  flex: 1;
  overflow-wrap: anywhere;
}

.table-filter-range {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto 1fr;
}

.table-filter-dates {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-filter-dates label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.table-filter-actions {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding-top: 10px;
}

.parent-icon {
  color: var(--purple);
  margin-left: 6px;
}

@media (max-width: 760px) {
  .data-table.responsive thead {
    display: none;
  }

  .data-table.responsive, .data-table.responsive tbody, .data-table.responsive tr, .data-table.responsive td {
    display: block;
    width: 100%;
  }

  .data-table.responsive tr {
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }

  .data-table.responsive tbody tr:last-child {
    border-bottom: 0;
  }

  .data-table.responsive td {
    align-items: flex-start;
    border: 0;
    display: flex;
    gap: 12px;
    padding: 4px 0;
  }

  .data-table.responsive td[data-label]::before {
    color: var(--text-muted);
    content: attr(data-label);
    flex: 0 0 34%;
    font-size: 0.76rem;
    font-weight: 600;
    padding-top: 2px;
    text-transform: uppercase;
  }

  .data-table.responsive td.cell-primary {
    font-size: 1rem;
  }

  .data-table.responsive td.cell-primary::before {
    display: none;
  }

  .data-table.responsive td.cell-primary {
    display: block;
  }

  .data-table.responsive td.cell-actions {
    justify-content: flex-end;
    text-align: left;
    width: 100%;
  }

  .cell-wrap {
    max-width: none;
  }
}

/**
 * Properties
 */
.properties {
  display: grid;
  gap: 8px 16px;
  grid-template-columns: max-content minmax(0, 1fr);
  margin: 0;
}

.properties dt {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.properties dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.properties-compact {
  font-size: 0.85rem;
  gap: 4px 12px;
}

@media (max-width: 480px) {
  .properties {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .properties dd {
    margin-bottom: 8px;
  }
}

/**
 * Metrics, meters
 */
.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--tone, var(--border-strong));
  border-radius: var(--radius);
  padding: 10px 14px;
}

.card .metric {
  background: var(--surface-2);
}

.metric-label {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.8rem;
  gap: 6px;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.3;
}

.metric-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.meter {
  background: var(--surface-3);
  border-radius: 999px;
  height: 6px;
  margin: 4px 0;
  overflow: hidden;
  width: 100%;
}

.meter-bar {
  background: var(--tone, var(--accent));
  border-radius: 999px;
  height: 100%;
}

/**
 * Tabs
 */
.tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  align-items: center;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  display: inline-flex;
  font-weight: 500;
  gap: 7px;
  padding: 10px 14px;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.tab-count {
  background: var(--surface-3);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0 7px;
}

.tab-panel > * + * {
  margin-top: 16px;
}

.area-panel-owner {
  margin-bottom: 8px;
}

/**
 * Modal
 */
.modal-backdrop {
  background: rgba(10, 14, 20, 0.5);
  inset: 0;
  position: fixed;
  z-index: 80;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  left: 50%;
  max-height: calc(100vh - 48px);
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 24px));
  z-index: 81;
}

.modal-small {
  width: min(480px, calc(100vw - 24px));
}

.modal-large {
  width: min(880px, calc(100vw - 24px));
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
}

.modal-body {
  overflow-y: auto;
  padding: 16px;
}

.modal-body > * + * {
  margin-top: 12px;
}

.modal-footer {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
}

/**
 * Home
 */
.customize-hidden {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
}

.widget-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.widget-wide {
  grid-column: 1 / -1;
}

.widget-editing {
  border-style: dashed;
  border-color: var(--accent);
}

.widget-tools {
  display: flex;
  gap: 2px;
}

.widget-footnote {
  margin-top: 10px;
}

@media (max-width: 1100px) {
  .widget-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.analysis-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.analysis-header .button {
  margin-left: auto;
}

.analysis-summary {
  font-size: 0.98rem;
  margin: 10px 0;
}

.bullet-list {
  margin: 0;
  padding-left: 20px;
}

.bullet-list li {
  margin: 3px 0;
}

.bullet-accent li::marker {
  color: var(--accent);
}

.incident-title {
  font-weight: 600;
}

.stage-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  margin-bottom: 10px;
}

.stage-chip {
  background: var(--tone-soft);
  border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
  border-radius: var(--radius-small);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
}

.stage-chip:hover {
  text-decoration: none;
  filter: brightness(0.97);
}

.stage-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.stage-count {
  color: var(--tone);
  font-size: 1.1rem;
  font-weight: 650;
}

/**
 * Edge map
 */
.edge-map-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.edge-map-layout.has-selection {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.map-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  grid-column: 1 / -1;
}

.map-search {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  display: flex;
  flex: 1 1 240px;
  gap: 6px;
  max-width: 360px;
  padding: 0 8px;
}

.map-search input {
  background: transparent;
  border: 0;
  color: var(--text);
  flex: 1;
  min-width: 0;
  outline: none;
  padding: 6px 0;
}

.map-search:focus-within {
  border-color: var(--accent);
}

.map-control {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.map-control select {
  max-width: 170px;
}

.map-toggles {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toggle-chip {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.8rem;
  gap: 5px;
  padding: 3px 10px;
}

.toggle-chip:hover {
  border-color: var(--accent);
}

.toggle-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.map-search-message {
  flex-basis: 100%;
}

.edge-map-compact .edge-map {
  height: 280px;
}

.edge-map-compact .metro-panel {
  max-height: 280px;
}

.edge-map-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.edge-map {
  background: #c9dcef;
  height: 440px;
  width: 100%;
  z-index: 0;
}

[data-theme='dark'] .edge-map {
  background: #0b1520;
}

.map-legend {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-radius: var(--radius-small);
  bottom: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.75rem;
  gap: 4px 10px;
  left: 8px;
  max-width: calc(100% - 16px);
  padding: 5px 9px;
  position: absolute;
  z-index: 500;
}

.legend-item {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}

.legend-dot {
  background: var(--status, var(--neutral));
  border-radius: 50%;
  display: inline-block;
  flex: none;
  height: 10px;
  width: 10px;
}

.legend-toggle {
  background: none;
  border: 0;
  border-radius: var(--radius-small);
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 1px 3px;
}

.legend-toggle:hover {
  background: var(--surface-3);
}

.legend-toggle.hidden {
  opacity: 0.45;
  text-decoration: line-through;
}

.legend-line {
  border-top: 2px solid var(--accent);
  display: inline-block;
  width: 18px;
}

.legend-line-fallback {
  border-top-style: dashed;
  opacity: 0.6;
}

.legend-parent {
  background: transparent;
  border: 2px solid var(--purple);
  outline: 1px solid var(--purple);
  outline-offset: 1px;
}

.map-marker-host {
  background: none;
  border: 0;
}

.map-marker {
  align-items: center;
  background: var(--status, var(--neutral));
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 11px;
  font-weight: 700;
  justify-content: center;
  opacity: 0.92;
  transition: transform 0.12s ease;
}

.map-marker:hover {
  opacity: 1;
  transform: scale(1.12);
}

.map-marker.parent {
  box-shadow: 0 0 0 3px var(--purple), 0 1px 6px rgba(0, 0, 0, 0.4);
}

.map-marker.selected {
  box-shadow: 0 0 0 4px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.45);
  opacity: 1;
  transform: scale(1.18);
}

.map-marker.focused {
  box-shadow: 0 0 0 4px var(--warning), 0 2px 10px rgba(0, 0, 0, 0.5);
  opacity: 1;
  transform: scale(1.22);
}

.map-link {
  fill: none;
  opacity: 0.55;
  stroke: var(--status, var(--accent));
  stroke-linecap: round;
  transition: opacity 0.12s ease;
}

.map-link.status-online {
  stroke: var(--accent);
}

.map-link.fallback {
  opacity: 0.3;
  stroke-dasharray: 6 5;
}

.map-link.related {
  opacity: 1;
}

.map-link.dimmed {
  opacity: 0.12;
}

.map-link:hover {
  opacity: 1;
}

.map-marker.status-unhealthy, .map-marker.status-degraded {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--status) 35%, transparent);
  }
}

.leaflet-container {
  font-family: var(--font);
}

[data-theme='dark'] .leaflet-bar a, [data-theme='dark'] .leaflet-control-attribution {
  background: var(--surface-2);
  color: var(--text-muted);
}

.metro-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 440px;
  overflow: hidden;
}

.metro-panel-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 10px 12px;
}

.metro-panel-header h3 {
  margin: 0;
}

.metro-environments {
  overflow-y: auto;
  padding: 0 12px;
}

.metro-environments tr.focused {
  background: var(--warning-soft);
}

@media (max-width: 960px) {
  .edge-map-layout.has-selection {
    grid-template-columns: minmax(0, 1fr);
  }

  .edge-map {
    height: 340px;
  }
}

/**
 * Customers
 */
.change-title {
  flex: 1;
  min-width: 0;
}

.change-description {
  margin: 12px 0;
}

.rollout {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  overflow-x: auto;
  padding: 0 0 4px;
}

.rollout-stage {
  border-top: 4px solid var(--tone);
  display: flex;
  flex: 1 0 96px;
  flex-direction: column;
  font-size: 0.78rem;
  padding: 6px 4px 0;
}

.rollout-dot {
  display: none;
}

.rollout-name {
  font-weight: 600;
}

.rollout-status {
  color: var(--tone);
}

.chart-cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
}

.note-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  min-height: 120px;
  padding: 10px;
}

/**
 * Areas
 */
.area-section + .area-section {
  margin-top: 24px;
}

.tool-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}

.tool-card {
  align-items: flex-start;
  color: var(--text);
  display: flex;
  gap: 12px;
  padding: 14px 16px;
}

.tool-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.tool-icon {
  align-items: center;
  background: var(--accent-soft);
  border-radius: var(--radius-small);
  color: var(--accent);
  display: inline-flex;
  flex: none;
  font-size: 1.1rem;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.tool-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.tool-title {
  font-weight: 600;
}

/**
 * Code, markdown, diff, charts
 */
.code-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  overflow: hidden;
}

.code-header {
  align-items: center;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  font-size: 0.8rem;
  gap: 8px;
  padding: 2px 4px 2px 12px;
}

.code-header > span:first-child {
  flex: 1;
  font-weight: 600;
}

.code-language {
  color: var(--text-muted);
  text-transform: uppercase;
}

.code-header .button-icon {
  height: 28px;
  width: 28px;
}

.code-block pre, .markdown pre {
  background: var(--surface-2);
  margin: 0;
  max-height: 520px;
  overflow: auto;
  padding: 10px 12px;
}

.markdown {
  overflow-wrap: anywhere;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown pre {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  margin: 8px 0;
}

.markdown table {
  border-collapse: collapse;
  margin: 8px 0;
}

.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 4px 8px;
}

.markdown blockquote {
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
  margin: 8px 0;
  padding-left: 12px;
}

.markdown .mermaid {
  background: var(--surface);
  display: flex;
  justify-content: center;
  margin: 8px 0;
  overflow-x: auto;
}

.mermaid-error {
  color: var(--danger);
  font-family: var(--font-mono);
}

.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-meta .hljs-keyword { color: #0f5fbd; }
.hljs-string, .hljs-attr + .hljs-string, .hljs-regexp { color: #a3361b; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: #7a3fb8; }
.hljs-number, .hljs-literal { color: #0b7a55; }
.hljs-comment, .hljs-quote { color: #6a7685; font-style: italic; }
.hljs-title, .hljs-section, .hljs-type, .hljs-class .hljs-title { color: #8b5d00; }
.hljs-addition { background: var(--success-soft); color: var(--success); }
.hljs-deletion { background: var(--danger-soft); color: var(--danger); }
[data-theme='dark'] .hljs-keyword, [data-theme='dark'] .hljs-selector-tag, [data-theme='dark'] .hljs-built_in { color: #6cb6ff; }
[data-theme='dark'] .hljs-string, [data-theme='dark'] .hljs-regexp { color: #f0a074; }
[data-theme='dark'] .hljs-attr, [data-theme='dark'] .hljs-attribute, [data-theme='dark'] .hljs-variable, [data-theme='dark'] .hljs-property { color: #c7a2ff; }
[data-theme='dark'] .hljs-number, [data-theme='dark'] .hljs-literal { color: #6fd6a8; }
[data-theme='dark'] .hljs-comment, [data-theme='dark'] .hljs-quote { color: #8591a3; }
[data-theme='dark'] .hljs-title, [data-theme='dark'] .hljs-section, [data-theme='dark'] .hljs-type { color: #e5c07b; }

.diff {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  overflow: hidden;
}

.diff-toolbar {
  align-items: center;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  padding: 4px 6px 4px 12px;
}

.diff-stats {
  display: flex;
  flex: 1;
  font-weight: 600;
  gap: 8px;
}

.diff-scroll {
  max-height: 560px;
  overflow: auto;
}

.diff-table {
  border-collapse: collapse;
  font-size: 0.8rem;
  table-layout: auto;
  width: 100%;
}

.diff-table th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  padding: 4px 8px;
  text-align: left;
}

.diff-table td {
  padding: 0 8px;
  vertical-align: top;
}

.diff-number {
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  width: 1%;
}

.diff-marker {
  user-select: none;
  width: 1%;
}

.diff-text {
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-split .diff-text {
  width: 49%;
}

.diff-added, td.diff-added { background: color-mix(in srgb, var(--success) 14%, transparent); }
.diff-removed, td.diff-removed { background: color-mix(in srgb, var(--danger) 14%, transparent); }
td.diff-empty { background: var(--surface-2); }

.chart {
  margin: 0;
}

.chart figcaption {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.chart figcaption strong {
  font-size: 1.1rem;
}

.chart-svg {
  display: block;
  height: 160px;
  width: 100%;
}

.chart-axis, .chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-grid {
  stroke-dasharray: 4 4;
}

.chart-line {
  fill: none;
  stroke: var(--tone, var(--accent));
  stroke-width: 2;
}

.chart-area {
  fill: color-mix(in srgb, var(--tone, var(--accent)) 14%, transparent);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  font-size: 0.75rem;
  gap: 8px;
  justify-content: space-between;
  margin-top: 4px;
}

.chart-empty {
  padding: 24px 0;
  text-align: center;
}

/**
 * Blazor
 */
#blazor-error-ui {
  background: var(--warning-soft);
  bottom: 0;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.2);
  color: var(--text);
  display: none;
  left: 0;
  padding: 10px 20px;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 12px;
  top: 8px;
}

.nowrap {
  white-space: nowrap;
}

/**
 * Timestamps
 */
.timestamp {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 6px;
  white-space: nowrap;
}

.timestamp-stacked {
  flex-direction: column;
  gap: 0;
}

.timestamp-secondary, .timestamp-relative {
  color: var(--text-muted);
  font-size: 0.85em;
}

.timestamp-zone {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-left: 3px;
}

.topbar-clock {
  align-items: center;
  border-radius: var(--radius-small);
  color: var(--text);
  display: inline-flex;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  gap: 8px;
  padding: 4px 8px;
  white-space: nowrap;
}

.topbar-clock:hover {
  background: var(--surface-3);
  text-decoration: none;
}

@media (max-width: 760px) {
  .topbar-clock-secondary {
    display: none;
  }
}

@media (max-width: 480px) {
  .topbar-clock {
    display: none;
  }
}

/**
 * Widgets
 */
.widget .card-header h2 {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.widget .card-header h2 .icon {
  color: var(--accent);
}

.widget-source {
  align-self: center;
  margin-right: 4px;
  white-space: nowrap;
}

.home-customizing {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.home-customizing .widget-picker {
  max-height: calc(100vh - var(--topbar-height) - var(--ribbon-height) - 32px);
  overflow-y: auto;
  position: sticky;
  top: calc(var(--topbar-height) + var(--ribbon-height) + 16px);
}

@media (max-width: 1100px) {
  .home-customizing {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-customizing .widget-picker {
    max-height: none;
    order: -1;
    position: static;
  }
}

.widget-picker .card-header {
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.widget-picker-group + .widget-picker-group {
  margin-top: 12px;
}

.widget-picker-area {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 6px;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.widget-picker-items {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.widget-picker-item {
  align-items: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-small);
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
}

.widget-picker-item > span:nth-child(2) {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.widget-picker-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/**
 * Charts
 */
.chart-hit {
  cursor: crosshair;
  fill: transparent;
}

.chart-hit:hover {
  fill: color-mix(in srgb, var(--accent) 10%, transparent);
}
