/*
 * CI/CD dashboard theme.
 * Tokens stay as bare HSL channels because templates use hsl(var(--token) / alpha) inline.
 */
:root {
  --background: 220 27% 9%;
  --foreground: 220 20% 92%;
  --card: 220 25% 12%;
  --card-foreground: 220 20% 92%;
  --popover: 221 24% 14%;
  --popover-foreground: 220 20% 92%;
  --muted: 221 24% 15%;
  --muted-foreground: 221 12% 62%;
  --border: 221 20% 21%;
  --input: 221 20% 24%;
  --accent: 221 22% 19%;
  --accent-foreground: 220 20% 96%;
  --primary: 39 87% 62%;
  --primary-foreground: 38 60% 8%;
  --secondary: 221 24% 16%;
  --secondary-foreground: 220 20% 92%;
  --destructive: 358 70% 58%;
  --destructive-foreground: 0 0% 100%;
  --ring: 39 87% 62%;

  --ok: 158 50% 48%;
  --warn: 39 87% 62%;
  --bad: 358 72% 62%;
  --info: 214 80% 66%;
  --idle: 221 10% 45%;

  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: hsl(var(--primary));
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
}

.mono {
  font-size: 0.8125rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.header-menu-open {
  overflow: hidden;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 3.5rem;
  padding: 0 clamp(1rem, 3vw, 2rem);
  background: hsl(var(--background) / 0.9);
  border-bottom: 1px solid hsl(var(--border));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

/* Three stacked rack units — the one decorative mark in the UI. */
.brand-mark {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.brand-mark span {
  display: block;
  width: 18px;
  height: 4px;
  border-radius: 1px;
  background: hsl(var(--muted-foreground) / 0.5);
  position: relative;
}

.brand-mark span::after {
  content: '';
  position: absolute;
  right: 2px;
  top: 1px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: hsl(var(--ok));
}

.brand-mark span:nth-child(2)::after {
  background: hsl(var(--primary));
}

.header-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
  white-space: nowrap;
}

.header-host {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-toggle {
  display: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  align-items: center;
  justify-content: center;
}

.header-toggle:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.header-divider {
  width: 1px;
  height: 1.25rem;
  background: hsl(var(--border));
  margin: 0 0.375rem;
}

.header-avatar {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: hsl(var(--accent));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  font-size: 0.75rem;
  font-weight: 600;
}

/* Layout */
.page {
  padding-bottom: 4rem;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem);
}

.section {
  margin-top: 2.25rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title i {
  color: hsl(var(--muted-foreground));
}

.section-subtitle {
  margin-top: 0.125rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

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

/* Incident banner */
.health-banner {
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: hsl(var(--bad) / 0.08);
  border: 1px solid hsl(var(--bad) / 0.45);
  color: hsl(var(--foreground));
  font-size: 0.875rem;
}

.health-banner-icon {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.0625rem;
  border-radius: 50%;
  background: hsl(var(--bad));
  color: hsl(var(--background));
  font-size: 0.625rem;
  flex-shrink: 0;
  animation: led-blink 1.6s ease-in-out infinite;
}

.health-banner-list {
  list-style: none;
  display: grid;
  gap: 0.25rem;
}

.health-banner-list time {
  margin-left: 0.375rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

/* Summary strip */
.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}

.summary-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-right: 1px solid hsl(var(--border));
  min-width: 0;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.summary-label {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.summary-meta {
  color: hsl(var(--muted-foreground) / 0.75);
}

.summary-meta::before {
  content: '(';
}

.summary-meta::after {
  content: ')';
}

.summary-item--alert .summary-value {
  color: hsl(var(--warn));
}

.summary-refresh {
  margin-left: auto;
  align-self: center;
  margin-right: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 0.875rem;
  height: 2.25rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--input));
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  font-weight: 600;
}

.btn-primary:hover {
  background: hsl(var(--primary) / 0.88);
  border-color: hsl(var(--primary) / 0.88);
}

.btn-danger {
  background: hsl(var(--bad) / 0.12);
  color: hsl(var(--bad));
  border-color: hsl(var(--bad) / 0.4);
}

.btn-danger:hover {
  background: hsl(var(--bad) / 0.2);
  border-color: hsl(var(--bad) / 0.6);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: hsl(var(--muted-foreground));
}

.btn-ghost:hover {
  background: hsl(var(--accent));
  border-color: transparent;
  color: hsl(var(--foreground));
}

.btn-small {
  padding: 0 0.625rem;
  height: 1.875rem;
  font-size: 0.8125rem;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:hover,
.icon-btn[aria-expanded='true'] {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.icon-btn--go {
  color: hsl(var(--ok));
}

.icon-btn--tiny {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.75rem;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  border-bottom: 1px dashed hsl(var(--muted-foreground) / 0.5);
}

.link-btn:hover {
  color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

/* Filter chips and search */
.filter-chips {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.1875rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 1.75rem;
  padding: 0 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.chip:hover {
  color: hsl(var(--foreground));
}

.chip--active {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.chip-count {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.chip--alert .chip-count {
  color: hsl(var(--warn));
  font-weight: 600;
}

.search-field {
  width: 15rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.25rem 0 0.75rem;
  height: 2.25rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.search-field:focus-within {
  border-color: hsl(var(--ring) / 0.7);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.875rem;
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-field input::placeholder {
  color: hsl(var(--muted-foreground));
}

.search-clear {
  display: inline-grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

.search-clear:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.search-clear:disabled {
  visibility: hidden;
}

/* Rack: the app and service list */
.rack {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  overflow: hidden;
}

.rack-row {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.5fr) 6.5rem 7.5rem 11rem;
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 0.75rem 0.625rem 1rem;
  border-top: 1px solid hsl(var(--border));
  position: relative;
  min-height: 3.75rem;
}

.rack-row:first-child {
  border-top: 0;
}

.rack-row:hover {
  background: hsl(var(--accent) / 0.45);
}

.rack--services .rack-row {
  grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.5fr) 6.5rem 11rem;
}

.row-main {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
}

/* Status LED */
.led {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: hsl(var(--idle));
}

.led--running {
  background: hsl(var(--ok));
  box-shadow: 0 0 0 3px hsl(var(--ok) / 0.15), 0 0 8px hsl(var(--ok) / 0.55);
}

.led--warn {
  background: hsl(var(--warn));
  box-shadow: 0 0 0 3px hsl(var(--warn) / 0.15), 0 0 8px hsl(var(--warn) / 0.5);
}

.led--error {
  background: hsl(var(--bad));
  box-shadow: 0 0 0 3px hsl(var(--bad) / 0.18), 0 0 8px hsl(var(--bad) / 0.6);
  animation: led-blink 1.6s ease-in-out infinite;
}

.led--stopped {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px hsl(var(--idle));
}

.led--idle {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px hsl(var(--idle) / 0.6);
}

@keyframes led-blink {
  50% {
    opacity: 0.35;
  }
}

.row-identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.row-name {
  align-self: flex-start;
  max-width: 100%;
  font-weight: 600;
  font-size: 0.9375rem;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-name:hover {
  color: hsl(var(--primary));
}

.rack-row--stopped .row-name,
.rack-row--idle .row-name {
  color: hsl(var(--muted-foreground));
}

.row-sub {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  white-space: nowrap;
}

.row-type,
.row-branch {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.row-type i,
.row-branch i {
  font-size: 0.75rem;
  opacity: 0.8;
}

.row-commit {
  display: inline-flex;
  gap: 0.4rem;
  min-width: 0;
  overflow: hidden;
}

.row-commit .mono {
  color: hsl(var(--foreground) / 0.75);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.row-commit-msg {
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-link {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.row-url {
  color: hsl(var(--foreground) / 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.row-url:hover {
  color: hsl(var(--primary));
}

.url-host {
  color: hsl(var(--muted-foreground));
}

.url-path {
  color: hsl(var(--foreground) / 0.9);
}

.icon-slot {
  width: 1.875rem;
  flex-shrink: 0;
}

.row-muted {
  color: hsl(var(--muted-foreground) / 0.7);
  font-size: 0.8125rem;
}

.row-deploy,
.row-resources {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.row-resources .mono {
  font-size: 0.75rem;
}

.deploy-result {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.125rem 0.375rem;
  margin-left: -0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.deploy-result:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.deploy-result i {
  font-size: 0.6875rem;
}

.deploy-result--ok i {
  color: hsl(var(--ok));
}

.deploy-result--fail {
  color: hsl(var(--bad));
}

.deploy-result--live {
  color: hsl(var(--primary));
}

/* Components set their own display, which would otherwise beat the attribute */
[hidden] {
  display: none !important;
}

.health-tag {
  font-size: 0.75rem;
  padding: 0.0625rem 0.5rem;
  border-radius: 999px;
  border: 1px solid;
}

.health-tag--healthy {
  color: hsl(var(--ok));
  border-color: hsl(var(--ok) / 0.35);
}

.health-tag--unhealthy {
  color: hsl(var(--warn));
  border-color: hsl(var(--warn) / 0.4);
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.125rem;
}

.btn-deploy {
  margin-right: 0.25rem;
}

.btn-deploy i {
  font-size: 0.75rem;
  color: hsl(var(--primary));
}

.btn-deploy:hover {
  border-color: hsl(var(--primary) / 0.6);
}

.rack-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

/* Loading placeholders */
.skeleton {
  display: block;
  border-radius: 4px;
  background: linear-gradient(90deg, hsl(var(--muted)) 0%, hsl(var(--accent)) 50%, hsl(var(--muted)) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton--dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.skeleton--title {
  width: 9rem;
  height: 0.75rem;
  margin: 0.2rem 0 0.35rem;
}

.skeleton--sub {
  width: 14rem;
  max-width: 100%;
  height: 0.5625rem;
}

.skeleton--url {
  width: 12rem;
  max-width: 100%;
  height: 0.625rem;
}

.rack-row--skeleton:hover {
  background: none;
}

@keyframes skeleton-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* Floating row menu */
.row-menu {
  position: fixed;
  z-index: 900;
  min-width: 13rem;
  padding: 0.3125rem;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: menu-in 0.12s ease-out;
}

.row-menu[hidden] {
  display: none;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.row-menu__item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  text-align: left;
}

.row-menu__item:hover,
.row-menu__item:focus-visible {
  background: hsl(var(--accent));
  outline: none;
  text-decoration: none;
  color: hsl(var(--foreground));
}

.row-menu__item i {
  width: 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.row-menu__item--danger,
.row-menu__item--danger i {
  color: hsl(var(--bad));
}

.row-menu__item--danger:hover,
.row-menu__item--danger:focus-visible {
  background: hsl(var(--bad) / 0.12);
  color: hsl(var(--bad));
}

.row-menu__divider {
  height: 1px;
  margin: 0.3125rem 0.25rem;
  background: hsl(var(--border));
}

/* Shared bits used inside modals */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
}

.badge-success {
  background: hsl(var(--ok) / 0.12);
  color: hsl(var(--ok));
  border-color: hsl(var(--ok) / 0.35);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: hsl(222 40% 3% / 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1.5rem;
  animation: modal-fade 0.15s ease-out;
}

.modal.active {
  display: flex;
}

@keyframes modal-fade {
  from {
    opacity: 0;
  }
}

.modal-content {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) + 2px);
  width: min(960px, 95vw);
  max-height: 92vh;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  animation: modal-rise 0.18s ease-out;
}

@keyframes modal-rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem 0.875rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.modal-header h2 {
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
}

.close-btn {
  font-size: 1.125rem;
  color: hsl(var(--muted-foreground));
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.close-btn:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

/* Form controls */
.form-group {
  margin-bottom: 1.125rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  color: hsl(var(--foreground));
  font-weight: 500;
  font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input[type='checkbox'],
.form-group input[type='radio'] {
  width: auto;
  accent-color: hsl(var(--primary));
}

.form-group textarea {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: hsl(var(--muted-foreground) / 0.8);
}

.form-group small {
  color: hsl(var(--muted-foreground));
}

/* Logs */
.logs-container {
  min-height: 24rem;
  max-height: 64vh;
  overflow: auto;
  padding: 0.75rem 1.25rem 1rem;
  background: hsl(222 30% 6%);
  color: hsl(220 16% 80%);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre;
  tab-size: 4;
}

.logs-container .list-placeholder {
  font-family: var(--font-sans);
  white-space: normal;
}

.t-err-soft {
  color: hsl(var(--bad) / 0.85);
}

.segmented {
  display: inline-flex;
  gap: 0.125rem;
  margin-left: auto;
  padding: 0.1875rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background) / 0.6);
}

.log-tab {
  height: 1.75rem;
  padding: 0 0.75rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  font-weight: 500;
}

.log-tab:hover {
  color: hsl(var(--foreground));
}

.log-tab.active {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

#errorLogsTab.active {
  color: hsl(var(--bad));
}

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0.5rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
  flex-wrap: wrap;
}

.log-toolbar .btn {
  margin-right: 0.25rem;
}

.log-source {
  margin-left: 0.5rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

.log-toolbar__options {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.log-toolbar__options label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
}

.log-toolbar__options input {
  accent-color: hsl(var(--primary));
}

.btn-live {
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / 0.5);
  background: hsl(var(--primary) / 0.08);
}

.btn-live .run-state-dot {
  width: 0.375rem;
  height: 0.375rem;
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

/* Modal layout helpers */
body.modal-open {
  overflow: hidden;
}

.modal-content--wide {
  width: min(1100px, 96vw);
}

.modal-content--narrow {
  width: min(560px, 95vw);
}

.modal-body--flush {
  padding: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.75rem 1.5rem;
  border-top: 1px solid hsl(var(--border));
  flex-wrap: wrap;
}

.modal-footer-note {
  margin-right: auto;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  min-width: 12rem;
  flex: 1;
}

.list-placeholder {
  list-style: none;
  padding: 2rem 1rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.list-placeholder--error {
  color: hsl(var(--bad));
}

/* Modal content building blocks */
.modal-lede {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.callout {
  margin-top: 1rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.5);
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.callout:first-child {
  margin-top: 0;
}

.callout--warn {
  border-color: hsl(var(--warn) / 0.4);
  background: hsl(var(--warn) / 0.07);
  color: hsl(var(--warn));
}

.callout--error {
  border-color: hsl(var(--bad) / 0.4);
  background: hsl(var(--bad) / 0.07);
  color: hsl(var(--bad));
}

.steps {
  counter-reset: step;
  list-style: none;
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.5rem;
  color: hsl(var(--foreground) / 0.9);
}

.modal-content:focus {
  outline: none;
}

.callout + .fact-list {
  margin-top: 0.75rem;
}

.steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  border: 1px solid hsl(var(--input));
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.copy-fields {
  display: grid;
  grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr) auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}

/* Rows share the parent's columns (subgrid) so every value lines up after the longest label. */
.copy-field {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.375rem 0.375rem 0.375rem 0.875rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.5);
}

@supports not (grid-template-columns: subgrid) {
  .copy-field {
    grid-template-columns: 10rem minmax(0, 1fr) auto;
  }
}

.copy-field:first-child {
  border-top: 0;
}

.copy-field[hidden] {
  display: none;
}

.copy-field-label {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.copy-field-value {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
  text-overflow: ellipsis;
}

.copy-field-value:focus {
  outline: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  background: hsl(var(--border));
  margin-bottom: 1.25rem;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.75rem 0.875rem;
  background: hsl(var(--card));
}

.stat-tile-label {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

.stat-tile-value {
  font-size: 1.0625rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-tile--warn .stat-tile-value {
  color: hsl(var(--warn));
}

.fact-list {
  display: grid;
  font-size: 0.875rem;
}

.fact-list > div {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid hsl(var(--border));
}

.fact-list > div:first-child {
  border-top: 0;
}

.fact-list dt {
  color: hsl(var(--muted-foreground));
}

.fact-list dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.fact-list .mono {
  font-size: 0.8125rem;
}

.fact-list a.mono {
  color: hsl(var(--foreground) / 0.9);
}

.modal-header h2 .led {
  margin-right: 0.125rem;
}

/* Sections inside modals */
.panel-section + .panel-section,
.panel-section + .settings-grid,
.settings-grid + .panel-section {
  margin-top: 1.75rem;
}

.settings-grid > .panel-section + .panel-section {
  margin-top: 0;
}

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.panel-section-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-section-header h3 i {
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
}

.meter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.meter {
  padding: 0.875rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background) / 0.5);
}

.meter-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.meter-label {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.meter-value {
  font-size: 1.375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.meter-track {
  height: 6px;
  margin: 0.5rem 0 0.375rem;
  border-radius: 3px;
  background: hsl(var(--muted));
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: hsl(var(--ok));
  transition: width 0.4s ease;
}

.meter-fill--warn {
  background: hsl(var(--warn));
}

.meter-fill--bad {
  background: hsl(var(--bad));
}

.meter-detail {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.input-with-action {
  display: flex;
  gap: 0.5rem;
}

.input-with-action input {
  flex: 1;
  min-width: 0;
}

.form-group > small {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  line-height: 1.45;
}

/* Tables inside modals */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0 0.75rem 0.5rem;
  text-align: left;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 500;
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}

.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: hsl(var(--accent) / 0.35);
}

.data-table-actions {
  text-align: right;
  white-space: nowrap;
}

.data-table-actions .btn,
.data-table-actions .icon-btn {
  vertical-align: middle;
}

.user-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.badge-accent {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / 0.35);
}

.icon-btn--danger:hover {
  background: hsl(var(--bad) / 0.12);
  color: hsl(var(--bad));
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

.form-row .checkbox-field,
.form-row .form-actions {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-bottom: 1.125rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.checkbox-field input {
  margin-top: 0.25rem;
  accent-color: hsl(var(--primary));
}

.checkbox-field small {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.access-list {
  list-style: none;
  display: grid;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.access-list .list-placeholder {
  padding: 0.75rem;
  text-align: left;
}

.access-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.375rem 0.375rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--background) / 0.5);
  font-size: 0.875rem;
}

.access-item > i {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
}

.access-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-field--select {
  margin-top: 0;
}

.inline-field select {
  flex: 1;
  min-width: 0;
  height: 2.25rem;
  padding: 0 0.625rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.875rem;
}

/* File manager */
.file-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem 0.625rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.file-toolbar label.btn {
  cursor: pointer;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.125rem;
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
}

button.crumb:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.crumb--current {
  color: hsl(var(--foreground));
  font-weight: 500;
}

.crumb i {
  font-size: 0.75rem;
  color: hsl(var(--warn));
}

.crumb-sep {
  color: hsl(var(--muted-foreground) / 0.5);
}

.file-drop {
  position: relative;
  min-height: 18rem;
  max-height: 64vh;
  overflow-y: auto;
  padding: 0.5rem 0.75rem 0.75rem;
}

.file-drop-hint {
  position: absolute;
  inset: 0.5rem;
  display: none;
  place-items: center;
  gap: 0.5rem;
  border: 2px dashed hsl(var(--primary) / 0.7);
  border-radius: var(--radius);
  background: hsl(var(--primary) / 0.06);
  color: hsl(var(--primary));
  font-weight: 500;
  pointer-events: none;
}

.file-drop--active .file-drop-hint {
  display: grid;
}

.file-row--folder {
  cursor: pointer;
}

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  max-width: 100%;
  font-weight: 500;
  text-align: left;
  overflow-wrap: break-word;
  word-break: break-word;
}

.data-table--files td:first-child {
  width: 100%;
}

button.file-name:hover {
  color: hsl(var(--primary));
}

.file-icon {
  width: 1rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}

.file-icon--folder {
  color: hsl(var(--warn));
}

.data-table--files td:nth-child(2),
.data-table--files td:nth-child(3) {
  white-space: nowrap;
  font-size: 0.8125rem;
}

.code-editor {
  display: block;
  width: 100%;
  min-height: 55vh;
  padding: 1rem 1.25rem;
  border: 0;
  resize: vertical;
  background: hsl(222 30% 6%);
  color: hsl(220 16% 86%);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  tab-size: 4;
}

.code-editor:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px hsl(var(--ring) / 0.4);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 0.0625rem 0.3125rem;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.6;
}

/* Small form and list pieces */
.subheading {
  margin: 1.25rem 0 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.label-hint {
  margin-left: 0.25rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 400;
}

.input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  overflow: hidden;
}

.input-group:focus-within {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
}

.input-addon {
  display: flex;
  align-items: center;
  padding: 0 0.25rem 0 0.75rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  white-space: nowrap;
}

.form-group .input-group input {
  border: 0;
  border-radius: 0;
  padding-left: 0;
  box-shadow: none;
}

.form-group .input-group input:focus {
  box-shadow: none;
}

.copy-field-actions {
  display: inline-flex;
  gap: 0.125rem;
}

.copy-field > .icon-btn,
.copy-field-actions {
  justify-self: end;
}

.copy-fields--editable .copy-field-value {
  padding: 0.3125rem 0.5rem;
  border-radius: var(--radius-sm);
}

.copy-fields--editable .copy-field-value:hover {
  box-shadow: inset 0 0 0 1px hsl(var(--input));
}

.copy-fields--editable .copy-field-value:focus {
  box-shadow: inset 0 0 0 1px hsl(var(--ring));
}

.copy-field-value[type='password'] {
  letter-spacing: 0.12em;
}

.backup-list {
  list-style: none;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  max-height: 60vh;
  overflow-y: auto;
}

.backup-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.875rem;
  padding: 0.625rem 0.75rem 0.625rem 1rem;
  border-top: 1px solid hsl(var(--border));
}

.backup-row:first-child {
  border-top: 0;
}

.backup-icon {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.backup-main {
  display: grid;
  min-width: 0;
}

.backup-when {
  font-size: 0.875rem;
  font-weight: 500;
}

.backup-meta {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backup-meta .mono {
  font-size: 0.6875rem;
}

.panel-section-header p {
  font-size: 0.8125rem;
}

/* Rollback: commit picker */
.commit-list {
  display: grid;
  max-height: 22rem;
  overflow-y: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

.commit-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem 0.875rem;
  border-top: 1px solid hsl(var(--border));
  cursor: pointer;
}

.commit-option:first-child {
  border-top: 0;
}

.commit-option:hover {
  background: hsl(var(--accent) / 0.5);
}

.commit-option:has(input:checked) {
  background: hsl(var(--primary) / 0.08);
  box-shadow: inset 2px 0 0 hsl(var(--primary));
}

.commit-option input {
  margin-top: 0.25rem;
  accent-color: hsl(var(--primary));
}

.commit-option-body {
  display: grid;
  gap: 0.125rem;
  min-width: 0;
}

.commit-option-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 500;
}

.commit-option-message {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commit-option-meta {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.commit-option-meta .mono {
  font-size: 0.75rem;
  color: hsl(var(--foreground) / 0.8);
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.inline-field label {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  white-space: nowrap;
}

.inline-field input {
  flex: 1;
  min-width: 0;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
}

.inline-field input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
}

/* Live run state (deploy output) */
.run-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 1.5rem;
  padding: 0 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  border: 1px solid hsl(var(--input));
  color: hsl(var(--foreground));
  flex-shrink: 0;
}

.run-state-dot {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.2);
  animation: led-blink 1.2s ease-in-out infinite;
}

.run-state[data-state='ok'] {
  color: hsl(var(--ok));
  border-color: hsl(var(--ok) / 0.4);
}

.run-state[data-state='ok'] .run-state-dot {
  background: hsl(var(--ok));
  box-shadow: 0 0 0 3px hsl(var(--ok) / 0.2);
  animation: none;
}

.run-state[data-state='fail'] {
  color: hsl(var(--bad));
  border-color: hsl(var(--bad) / 0.45);
}

.run-state[data-state='fail'] .run-state-dot {
  background: hsl(var(--bad));
  box-shadow: 0 0 0 3px hsl(var(--bad) / 0.2);
  animation: none;
}

.run-timer {
  margin-left: auto;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* Terminal output */
.terminal {
  margin: 0;
  min-height: 16rem;
  max-height: 62vh;
  overflow: auto;
  padding: 0.875rem 1.25rem 1rem;
  background: hsl(222 30% 6%);
  color: hsl(220 16% 80%);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre;
  tab-size: 4;
}

.terminal:empty::before {
  content: 'Waiting for output…';
  color: hsl(var(--muted-foreground));
}

.t-line {
  display: block;
  min-height: 1.2em;
}

.t-time {
  color: hsl(var(--muted-foreground) / 0.7);
  margin-right: 0.75rem;
  user-select: none;
}

.t-rule {
  color: hsl(var(--muted-foreground) / 0.4);
}

.t-err {
  color: hsl(var(--bad));
  background: hsl(var(--bad) / 0.08);
}

.t-warn {
  color: hsl(var(--warn));
}

.t-ok {
  color: hsl(var(--ok));
}

/* Deploy history */
.history-list {
  list-style: none;
  max-height: 64vh;
  overflow-y: auto;
}

.history-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid hsl(var(--border));
}

.history-row:first-child {
  border-top: 0;
}

.history-icon {
  display: inline-grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  font-size: 0.6875rem;
}

.history-icon--ok {
  color: hsl(var(--ok));
  background: hsl(var(--ok) / 0.12);
}

.history-icon--fail {
  color: hsl(var(--bad));
  background: hsl(var(--bad) / 0.12);
}

.history-icon--warn {
  color: hsl(var(--warn));
  background: hsl(var(--warn) / 0.12);
}

.history-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.625rem;
  font-size: 0.875rem;
}

.history-title .row-branch {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.history-title .mono {
  font-size: 0.75rem;
}

.history-title a.mono {
  color: hsl(var(--foreground) / 0.85);
}

.history-arrow {
  font-size: 0.625rem;
  color: hsl(var(--muted-foreground));
}

.history-meta {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.history-time {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  white-space: nowrap;
}

.history-main {
  display: grid;
  gap: 0.125rem;
  min-width: 0;
}

.history-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: hsl(var(--foreground) / 0.85);
  font-size: 0.8125rem;
}

.history-tried {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.history-side {
  display: grid;
  justify-items: end;
  gap: 0.375rem;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Toasts */
.toast-region {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: min(24rem, calc(100vw - 2rem));
  padding: 0.75rem 0.5rem 0.75rem 0.875rem;
  border-radius: var(--radius);
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--input));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast--leaving {
  animation: toast-out 0.18s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(12px);
  }
}

.toast-icon {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.0625rem;
  border-radius: 50%;
  font-size: 0.625rem;
  flex-shrink: 0;
  color: hsl(var(--background));
  background: hsl(var(--info));
}

.toast--success .toast-icon {
  background: hsl(var(--ok));
}

.toast--error .toast-icon {
  background: hsl(var(--bad));
}

.toast--warn .toast-icon {
  background: hsl(var(--warn));
}

.toast--error {
  border-color: hsl(var(--bad) / 0.45);
}

.toast-text {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.toast-close {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-sm);
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  flex-shrink: 0;
}

.toast-close:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

/* Confirm / prompt dialogs */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: hsl(222 40% 3% / 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: modal-fade 0.12s ease-out;
}

.dialog-overlay--leaving {
  opacity: 0;
  transition: opacity 0.12s ease-in;
}

.dialog {
  width: min(26rem, 100%);
  padding: 1.25rem 1.25rem 1rem;
  border-radius: calc(var(--radius) + 2px);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--input));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  animation: modal-rise 0.16s ease-out;
}

.dialog-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.dialog-message {
  margin-top: 0.375rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.dialog-field {
  display: block;
  margin-top: 1rem;
}

.dialog-field span {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.dialog-field input {
  width: 100%;
  padding: 0.5625rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.875rem;
}

.dialog-field input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.dialog--danger .dialog-title::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin: 0 0.5rem 0.125rem 0;
  border-radius: 50%;
  background: hsl(var(--bad));
  box-shadow: 0 0 0 3px hsl(var(--bad) / 0.18);
  vertical-align: middle;
}

.btn-danger-solid {
  background: hsl(var(--bad));
  border-color: hsl(var(--bad));
  color: hsl(0 0% 100%);
  font-weight: 600;
}

.btn-danger-solid:hover {
  background: hsl(var(--bad) / 0.88);
  border-color: hsl(var(--bad) / 0.88);
}

/* Responsive */
@media (max-width: 1100px) {
  .rack-row {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 6rem 11rem;
  }

  .rack-row .row-resources {
    display: none;
  }
}

@media (max-width: 900px) {
  .header-toggle {
    display: inline-flex;
  }

  .header-nav {
    position: fixed;
    top: 3.75rem;
    right: 1rem;
    left: 1rem;
    background: hsl(var(--popover));
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    padding: 0.5rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    display: none;
  }

  .header-nav--open {
    display: flex;
  }

  .header-nav .btn {
    justify-content: flex-start;
  }

  .header-divider {
    width: auto;
    height: 1px;
    margin: 0.25rem 0;
  }

  .summary-item {
    flex: 1 1 45%;
    border-bottom: 1px solid hsl(var(--border));
  }

  .summary-refresh {
    margin: 0.375rem auto;
  }

  .section-actions {
    width: 100%;
  }

  .search-field {
    flex: 1;
    width: auto;
    min-width: 10rem;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 1rem 1rem 3rem;
  }

  .section {
    margin-top: 1.75rem;
  }

  .summary-item {
    padding: 0.75rem 1rem;
  }

  .summary-value {
    font-size: 1.25rem;
  }

  .summary-meta {
    display: none;
  }

  .filter-chips {
    width: 100%;
    overflow-x: auto;
  }

  .chip {
    flex: 1;
    justify-content: center;
  }

  .rack-row,
  .rack--services .rack-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'main actions'
      'link deploy';
    row-gap: 0.375rem;
    column-gap: 0.75rem;
    padding: 0.75rem 0.5rem 0.75rem 0.875rem;
  }

  .row-main {
    grid-area: main;
  }

  .row-actions {
    grid-area: actions;
  }

  .row-link {
    grid-area: link;
    padding-left: 1.375rem;
  }

  .row-deploy {
    grid-area: deploy;
    justify-self: end;
    padding-right: 0.375rem;
  }

  .row-commit,
  .url-host,
  .icon-btn--logs {
    display: none;
  }

  .row-sub {
    overflow: hidden;
  }

  .btn-deploy {
    width: 1.875rem;
    padding: 0;
    font-size: 0;
    gap: 0;
  }

  .btn-deploy i {
    font-size: 0.8125rem;
  }

  .icon-btn,
  .icon-slot {
    width: 2.25rem;
    height: 2.25rem;
  }

  .btn-deploy {
    width: 2.25rem;
    height: 2.25rem;
  }

  .modal {
    padding: 0.5rem;
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-height: 94vh;
  }

  .modal-header {
    padding: 0.75rem 0.75rem 0.75rem 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

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

  .meter-grid,
  .stat-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .data-table--users th:nth-child(3),
  .data-table--users td:nth-child(3),
  .data-table-actions .btn-label {
    display: none;
  }

  .data-table--files th:nth-child(2),
  .data-table--files td:nth-child(2),
  .data-table--files th:nth-child(3),
  .data-table--files td:nth-child(3) {
    display: none;
  }

  .data-table th,
  .data-table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .file-toolbar,
  .log-toolbar {
    padding-left: 1rem;
  }

  .modal-footer {
    padding-left: 1rem;
  }

  .modal-footer-note {
    flex-basis: 100%;
  }

  .copy-field {
    padding-left: 0.625rem;
  }

  .fact-list > div {
    grid-template-columns: 6rem minmax(0, 1fr);
  }
}

@media (max-width: 420px) {
  .header-host {
    display: none;
  }

  .toast-region {
    right: 0.5rem;
    left: 0.5rem;
    bottom: 0.5rem;
    align-items: stretch;
  }

  .toast {
    width: auto;
  }

  .summary-item {
    flex-basis: 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
