/* Graphite Signal */
:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #eef1f3;
  --surface-3: #e3e7ea;
  --text: #0b0f14;
  --text-muted: #52606d;
  --text-subtle: #7a8793;
  --border: #d3d9df;
  --border-strong: #b9c2ca;
  --accent: #111827;
  --accent-hover: #000000;
  --accent-contrast: #ffffff;
  --accent-hover-contrast: #ffffff;
  --focus: #475569;

  --status-success: #0f7a3b;
  --status-success-bg: transparent;
  --status-failed: #b91c1c;
  --status-failed-contrast: #ffffff;
  --status-failed-bg: transparent;
  --status-running: #007481;
  --status-running-bg: transparent;
  --status-queued: #5f6872;
  --status-queued-bg: transparent;
  --status-canceled: #5f6872;
  --status-canceled-bg: transparent;
  --status-unknown: #5f6872;
  --status-unknown-bg: transparent;

  --font-sans:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-mono:
    "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-control: 4px;
  --radius-panel: 6px;
  --radius-layout: 8px;

  /* Compatibility aliases for existing templates. */
  --fg: var(--text);
  --fg-secondary: var(--text-muted);
  --fg-muted: var(--text-muted);
  --fg-faint: var(--text-subtle);
  --bg-subtle: var(--surface-2);
  --surface-hover: var(--surface-2);
  --surface-raised: var(--surface);
  --border-subtle: var(--border);
  --accent-fg: var(--accent);
  --accent-bg: var(--surface-2);
  --green-fg: var(--status-success);
  --green-bg: transparent;
  --red-fg: var(--status-failed);
  --red-bg: transparent;
  --amber-fg: var(--status-running);
  --amber-bg: transparent;
  --radius-sm: var(--radius-control);
  --radius: var(--radius-panel);
  --radius-lg: var(--radius-layout);
  --radius-xl: var(--radius-layout);
  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090b0e;
    --surface: #101419;
    --surface-2: #151a20;
    --surface-3: #1c232b;
    --text: #f4f6f8;
    --text-muted: #a2adb8;
    --text-subtle: #77838f;
    --border: #26313c;
    --border-strong: #3a4652;
    --accent: #f4f6f8;
    --accent-hover: #ffffff;
    --accent-contrast: #090b0e;
    --accent-hover-contrast: #090b0e;
    --focus: #94a3b8;
    --status-success: #22c55e;
    --status-failed: #f87171;
    --status-failed-contrast: #090b0e;
    --status-running: #22d3ee;
    --status-queued: #cbd5e1;
    --status-canceled: #cbd5e1;
    --status-unknown: #cbd5e1;
  }
}

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

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
  transition:
    color 100ms ease,
    background-color 100ms ease,
    border-color 100ms ease;
}

.link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

a:hover,
.link:hover {
  color: var(--text);
  text-decoration-color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

code,
pre,
.mono,
.numeric,
.path-short,
.hash-short {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  font-weight: 450;
}

code {
  padding: 2px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}

pre {
  padding: 12px;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  width: 250px;
  min-width: 250px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  height: 48px;
  padding: 12px 14px;
}

.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 0;
}

.brand-name {
  font-size: 14px;
  line-height: 18px;
  font-weight: 650;
}

.brand-subtitle {
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 13px;
}

.sidebar-panel {
  margin: 0 10px 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
}

.sidebar-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-panel-header strong {
  font-size: 12px;
  line-height: 16px;
  font-weight: 680;
}

.sidebar-panel-header span {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
}

.builder-list {
  display: grid;
  gap: 0;
  padding: 8px;
  list-style: none;
}

.sidebar-panel-header .numeric {
  font-family: inherit;
  font-size: 11px;
  line-height: 14px;
}

.builder-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  padding: 8px 4px;
}

.builder-list strong {
  font-size: 12px;
  line-height: 16px;
}

.builder-bar {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.builder-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.dashboard-nav {
  margin-bottom: 8px;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-label {
  margin: 14px 10px 6px;
  padding: 0;
  color: var(--text-subtle);
  font-size: 10px;
  line-height: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-links {
  display: grid;
  gap: 1px;
}

.nav-links a {
  display: flex;
  align-items: center;
  height: 28px;
  margin: 0 10px;
  padding: 0 8px 0 10px;
  color: var(--text-muted);
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--text);
  background: transparent;
  border-left-color: var(--border-strong);
}

.nav-links a.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: transparent;
  font-weight: 650;
}

.shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-title strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 16px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title span {
  display: block;
  overflow: hidden;
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
}

.command-input,
.topbar-search input {
  width: clamp(140px, 24vw, 420px);
  height: 28px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  font-size: 12px;
  line-height: 16px;
}

.command-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-subtle);
}

.topbar-actions,
.nav-auth {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  flex: 0 0 auto;
}

.nav-auth form {
  display: inline;
}

.page-main {
  flex: 1;
  min-width: 0;
}

.container {
  max-width: none;
  width: 100%;
  padding: 16px;
  box-sizing: border-box;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 16px;
  color: var(--text-subtle);
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 16px;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 26px;
  font-weight: 680;
  letter-spacing: 0;
}

h2,
h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 18px;
  font-weight: 650;
  letter-spacing: 0;
}

p {
  color: var(--text-muted);
}

.page-header,
.section-header,
.news-header,
.job-history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.operator-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px 16px;
}

.page-subtitle,
.refresh-state,
.text-muted,
.empty-hint,
.news-date,
.news-content,
.wizard-hint,
.admin-notice {
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 16px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 16px;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs .current {
  color: var(--text);
  font-weight: 550;
}

.panel,
.card,
.form-card,
.metric-card,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-header,
.card-header {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.panel-header h2,
.panel-header h3 {
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
  font-weight: 680;
}

.panel-header a,
.card-header a {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 550;
  text-decoration: none;
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.panel-actions .badge {
  font-size: 11px;
  line-height: 14px;
}

.panel-header a:hover,
.card-header a:hover {
  color: var(--text);
}

.card-body,
.form-card,
.metric-card {
  padding: 12px;
}

.panel-body {
  padding: 12px;
}

.panel-body > :last-child {
  margin-bottom: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.operator-primary,
.operator-sidebar {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.operator-sidebar {
  width: 300px;
}

.operator-header {
  margin-bottom: 12px;
}

.dashboard-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.operator-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.operator-header-actions form {
  display: inline-flex;
}

.operator-toolbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.dashboard-search {
  flex: 1 1 260px;
  width: auto;
  min-width: 0;
  max-width: 380px;
}

.dashboard-system {
  flex: 0 1 154px;
  width: 154px;
  min-width: 0;
}

.motd-line {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
}

.metric-cell {
  display: grid;
  gap: 4px;
  min-height: 116px;
  padding: 14px 16px;
  color: var(--text);
  border-top: 2px solid var(--border-strong);
  border-right: 1px solid var(--border);
  text-decoration: none;
}

.metric-cell:last-child {
  border-right: 0;
}

.metric-cell:hover {
  background: var(--surface-2);
}

.metric-cell span {
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
  font-weight: 680;
}

.metric-cell strong {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 30px;
  line-height: 34px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.metric-cell small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
}

.metric-success {
  border-top-color: var(--status-success);
}

.metric-success strong {
  color: var(--status-success);
}

.metric-failed {
  border-top-color: var(--status-failed);
}

.metric-failed strong {
  color: var(--status-failed);
}

.metric-running {
  border-top-color: var(--status-running);
}

.metric-running strong {
  color: var(--status-running);
}

.stats-grid,
.stat-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}

a.stat-card:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: none;
}

.stat-label {
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 24px;
  font-weight: 650;
}

.stat-value-red {
  color: var(--status-failed);
}

.health-ledger {
  padding: 0 10px;
}

.health-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  height: 30px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.health-row:hover {
  background: var(--surface-2);
}

.health-row:last-child {
  border-bottom: 0;
}

.health-label {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  font-weight: 650;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.health-value {
  color: var(--text);
  font-size: 13px;
  line-height: 16px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.health-value.health-failed {
  color: var(--status-failed);
}

.health-value.health-running {
  color: var(--status-running);
}

.health-value.health-queued {
  color: var(--status-queued);
}

.health-value.health-succeeded {
  color: var(--status-success);
}

.stat-value-green {
  color: var(--status-success);
}

.stat-value-yellow {
  color: var(--status-running);
}

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

.panel > .table-wrap,
.panel .compact-table-wrap {
  border: 0;
  border-radius: 0;
}

table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
}
.agents-table {
  table-layout: fixed;
  min-width: 64rem;
}
.agents-col-name {
  width: 16%;
}
.agents-col-host {
  width: 18%;
}
.agents-col-systems {
  width: 18%;
}
.agents-col-jobs {
  width: 8%;
}
.agents-col-status {
  width: 12%;
}
.agents-col-succeeded {
  width: 9%;
}
.agents-col-failed {
  width: 8%;
}
.agents-col-last-seen {
  width: 11%;
}
th,
td {
  height: 38px;
  padding: 0 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

td {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dense-table th,
.dense-table td {
  height: 38px;
}

th {
  color: var(--text-muted);
  background: var(--surface-2);
  font-size: 11px;
  line-height: 14px;
  font-weight: 650;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}
.sort-link {
  display: inline-grid;
  grid-template-columns: minmax(0, max-content) 0.75rem;
  align-items: center;
  gap: 0.35rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.sort-link:hover,
.sort-link:focus-visible,
.sort-link.is-active {
  color: var(--text);
}
.sort-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.sort-indicator {
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.75rem;
  min-width: 0.75rem;
  font-size: 0.625rem;
  letter-spacing: 0;
  line-height: 1;
}
.sort-indicator::before {
  content: "";
  display: block;
  border-left: 0.25rem solid transparent;
  border-right: 0.25rem solid transparent;
}
.sort-link.is-active .sort-indicator.sort-asc::before {
  border-bottom: 0.375rem solid currentColor;
}
.sort-link.is-active .sort-indicator.sort-desc::before {
  border-top: 0.375rem solid currentColor;
}
.sort-link.is-active .sort-indicator {
  color: inherit;
}
tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--surface-2);
}

.selectable-table tr:focus,
.selectable-table tr[aria-selected="true"] {
  background: var(--surface-2);
  outline: 0;
}

.selectable-table tr:focus td:first-child,
.selectable-table tr[aria-selected="true"] td:first-child {
  border-left: 2px solid var(--accent);
}

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

.nowrap {
  white-space: nowrap;
}

.truncate {
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status,
.badge,
.status-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--status-color, var(--status-unknown));
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  min-height: 16px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 560;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.status::before,
.badge::before,
.status-label::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 1px;
  background-color: currentColor;
}

.badge-succeeded,
.badge-completed,
.badge-success,
.badge-pass,
.status-completed,
.status-succeeded,
.status-success {
  --status-color: var(--status-success);
}

.badge-failed,
.badge-failure,
.badge-error,
.badge-aborted,
.status-aborted,
.status-failed,
.status-failure,
.status-error {
  --status-color: var(--status-failed);
}

.badge-running,
.badge-active,
.status-running,
.status-active {
  --status-color: var(--status-running);
}

.badge-pending,
.badge-queued,
.status-pending,
.status-queued {
  --status-color: var(--status-queued);
}

.badge-cancelled,
.badge-canceled,
.badge-skipped,
.status-cancelled,
.status-canceled,
.status-skipped {
  --status-color: var(--status-canceled);
}

.badge-unknown,
.status-unknown {
  --status-color: var(--status-unknown);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 2px;
  background: currentColor;
}

.status-dot-green,
.step-success {
  color: var(--status-success);
}

.status-dot-red,
.step-failure {
  color: var(--status-failed);
}

.status-dot-yellow {
  color: var(--status-running);
}

.status-dot-gray {
  color: var(--status-unknown);
}

.empty {
  min-height: 74px;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: 14px 10px;
  color: var(--text-muted);
  text-align: center;
  background: var(--surface);
  border: 0;
  border-radius: 0;
}

.compact-empty {
  min-height: 74px;
  margin: 0;
  padding: 14px 10px;
}

.empty-title {
  color: var(--text);
  font-size: 12px;
  line-height: 16px;
  font-weight: 650;
}

.failure-empty,
.section-empty {
  margin: 10px;
  padding: 16px 10px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}

.section-empty {
  padding: 14px 10px;
}

.filter-bar,
.filter-form,
.quick-actions,
.wizard-actions,
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.metrics-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.metrics-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 550;
}

.metrics-controls select {
  width: auto;
}

.panel .filter-bar {
  min-height: 42px;
  padding: 8px 10px;
  margin: 0;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.filter-bar input[type="search"] {
  flex: 1 1 220px;
  width: auto;
  min-width: 0;
}

.filter-bar select {
  flex: 0 1 110px;
  width: 110px;
  min-width: 0;
}

input,
select,
textarea,
.inline-input,
.filter-form input[type="text"],
.filter-form select,
.job-history-toolbar input,
.metrics-controls select,
.form-group input,
.form-group select,
.form-group textarea {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
}

input,
select,
.inline-input,
.filter-form input[type="text"],
.filter-form select,
.job-history-toolbar input,
.metrics-controls select,
.form-group input,
.form-group select {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 16px;
}

textarea,
.form-group textarea {
  min-height: 72px;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus,
.inline-input:focus,
.filter-form input:focus,
.filter-form select:focus,
.job-history-toolbar input:focus,
.metrics-controls select:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.btn,
button,
.filter-form button,
.bump-button,
.pagination a,
.quick-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  line-height: 16px;
  font-weight: 550;
  text-decoration: none;
  transition:
    color 100ms ease,
    background-color 100ms ease,
    border-color 100ms ease,
    opacity 100ms ease;
}

.topbar .btn,
.topbar button,
.filter-bar .btn,
.filter-bar button,
.filter-form .btn,
.filter-form button {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
}

.btn:hover,
button:hover,
.filter-form button:hover {
  color: var(--accent-hover-contrast);
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  opacity: 1;
}

.btn-secondary,
.bump-button,
.pagination a,
.quick-actions a {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn-secondary:hover,
.bump-button:hover,
.pagination a:hover,
.quick-actions a:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-ghost,
.nav-auth button {
  color: var(--text-muted);
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover,
.nav-auth button:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: transparent;
}

.btn-danger {
  color: var(--status-failed-contrast);
  background: var(--status-failed);
  border-color: var(--status-failed);
}

.btn-danger:hover {
  color: var(--status-failed-contrast);
  background: var(--status-failed);
  border-color: var(--status-failed);
}

.btn-small,
.btn-sm {
  height: 30px;
  padding: 0 10px;
}

.btn:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-card {
  max-width: 520px;
  margin-bottom: 16px;
}

.form-card-wide {
  max-width: 720px;
}

.form-group {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.form-group label,
.filter-form label,
.job-history-toolbar label {
  display: grid;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 550;
}

.form-group input[type="checkbox"] {
  width: auto;
  height: auto;
  accent-color: var(--accent);
}

.detail-grid {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin-bottom: 16px;
}

.detail-grid dt {
  color: var(--text-muted);
  font-weight: 550;
}

.detail-grid dd {
  min-width: 0;
  color: var(--text);
  word-break: break-word;
}

.tab-nav {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.tab-nav a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-weight: 550;
}

.tab-nav a:hover,
.tab-nav a.active {
  color: var(--text);
}

.tab-nav a.active {
  border-bottom-color: var(--accent);
}

.summary-list,
.worker-list,
.news-list {
  display: grid;
  gap: 0;
  list-style: none;
}

.summary-list li,
.worker-list li {
  border-bottom: 1px solid var(--border);
}

.summary-list li:last-child,
.worker-list li:last-child {
  border-bottom: 0;
}

.summary-list a,
.worker-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
}

.summary-list a:hover {
  background: var(--surface-2);
}

.worker-main,
.worker-side {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.worker-main {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.worker-main span {
  color: var(--text-subtle);
}

.panel-queue h3 {
  margin: 10px 10px 8px;
  padding: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 14px;
  font-weight: 650;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.split-grid,
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  height: 320px;
  padding: 16px;
}

.metric-card h3 {
  flex: 0 0 auto;
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 650;
}

.metric-card canvas {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
}

.metric-panel {
  display: flex;
  flex-direction: column;
  height: 356px;
}

.metric-chart-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 12px;
  min-height: 0;
}

.metric-chart-body canvas {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
}

.load-bar {
  position: relative;
  display: inline-flex;
  min-width: 88px;
  justify-content: center;
  align-items: center;
  padding: 2px 8px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  font-weight: 550;
  overflow: hidden;
}

.load-bar > span:first-child {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--load-percent, 0%);
  background: var(--accent);
  opacity: 0.18;
  z-index: 0;
}

.load-bar-text {
  position: relative;
  z-index: 1;
}

.flash-message {
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.flash-error {
  color: var(--status-failed);
  border-color: var(--status-failed);
}

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

.error-detail,
.error-log,
.error-log-raw {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
}

.error-detail,
.error-log-raw {
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.build-error {
  margin: 16px 0;
}

.error-log {
  list-style: none;
  max-height: 384px;
  overflow-y: auto;
}

.error-log-line {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-log-line:last-child {
  border-bottom: 0;
}

.error-log-error {
  color: var(--status-failed);
}

.error-log-warn {
  color: var(--status-running);
}

.error-log-notice,
.error-log-info {
  color: var(--text);
}

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 6px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.page-main:has(.login-container) {
  display: flex;
  flex-direction: column;
}

.page-main:has(.login-container) > .container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.login-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h1,
.login-subtitle {
  text-align: center;
}

.login-subtitle {
  margin: 4px 0 16px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.path-short,
.hash-short {
  display: inline-block;
  max-width: min(34rem, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.build-meta-value {
  min-width: 0;
}

.build-meta-value code,
.detail-grid dd code,
td > code {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

pre code {
  display: inline;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: inherit;
}

.text-sm {
  font-size: 12px;
  line-height: 16px;
}

.text-center {
  text-align: center;
}

.inline,
.inline-form {
  display: inline;
}

.row-actions {
  width: 10rem;
  max-width: none;
  overflow: visible;
  text-align: right;
  white-space: nowrap;
}

.outputs-detail,
.code-block + .code-block {
  margin-top: 12px;
}

.outputs-list {
  margin: 8px 0 0 20px;
}

@media (max-width: 1120px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .operator-sidebar {
    width: auto;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-cell:nth-child(3n) {
    border-right: 0;
  }
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .sidebar {
    width: 200px;
    min-width: 200px;
  }

  .brand-subtitle {
    display: none;
  }

  .topbar {
    gap: 10px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    min-width: 0;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .metric-cell:nth-child(3n) {
    border-right: 1px solid var(--border);
  }

  .metric-cell:nth-child(2n) {
    border-right: 0;
  }

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

  .topbar {
    position: static;
    height: auto;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .command-input,
  .topbar-search input {
    width: 100%;
  }

  .topbar-search .btn {
    flex: 0 0 auto;
  }

  .container {
    padding: 12px;
  }

  .page-header,
  .section-header,
  .job-history-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .operator-header {
    grid-template-columns: 1fr;
  }

  .operator-header-actions,
  .operator-toolbar {
    justify-content: flex-start;
    width: 100%;
  }

  .dashboard-search {
    width: min(100%, 380px);
  }

  .stats-grid,
  .split-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    height: 40px;
    padding: 6px 8px;
  }
}

/* Announcement banners */
.announcements {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.announcement-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.announcement-line span {
  flex: 1;
}

.announcement-close {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

/* Modal dialogs */
dialog {
  margin: auto;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-layout);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

dialog.dialog-sm {
  width: min(400px, calc(100vw - 32px));
}

body:has(#login-dialog[open]) .login-container {
  visibility: hidden;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  font-size: 14px;
  line-height: 18px;
  font-weight: 650;
}

.dialog-close {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.dialog-body {
  padding: 16px;
  overflow-y: auto;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

/* Page action toolbar */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* Make dashboard sidebar widgets stack nicely */
.operator-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
}

/* Better spacing inside build detail */
.build-detail-section {
  margin-bottom: 16px;
}

.build-detail-section > h2 {
  margin-bottom: 10px;
}

.build-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.build-meta-item {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
}

.build-meta-label {
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.build-meta-value {
  color: var(--text);
  font-size: 13px;
  line-height: 18px;
  word-break: break-word;
}

/* Running/pending panel header */
.panel-status-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-status-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Inline status badge count */
.badge-count {
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

/* Queue running/pending panels */
.panel-running {
  margin-bottom: 14px;
}

/* Section panel titles */
.section-title {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 650;
}

/* Content vertical rhythm.

   The global reset zeroes every margin, which is correct inside panels and
   cards (they manage their own padding) but leaves bare flow elements placed
   directly in a page's content area with no spacing, so detail pages collapse
   into a cramped, inconsistent stack. Restore rhythm for *direct* children of
   the page container only, so panel/card internals are left untouched. */
.container > h1 {
  margin-bottom: 12px;
}

.container > h2,
.container > h3 {
  margin-top: 20px;
  margin-bottom: 10px;
}

.container > p,
.container > dl,
.container > ul,
.container > ol,
.container > pre,
.container > table {
  margin-bottom: 12px;
}

.container > section,
.container > .panel,
.container > .table-wrap,
.container > .stats-grid,
.container > .build-error,
.container > .flash-message {
  margin-bottom: 16px;
}

/* Tighten the gap between a heading and the block it introduces. */
.container > h1 + p,
.container > h2 + p,
.container > h3 + p,
.container > h1 + .stats-grid,
.container > h2 + .stats-grid {
  margin-top: 0;
}

/* Never leave a trailing margin pushing against the footer. */
.container > :last-child {
  margin-bottom: 0;
}

/* Flatten nested boxes: an error/code block inside a flash message must not
   render its own surface and border on top of the flash panel's surface and
   border (double-boxing). Let the flash message be the single container. */
.flash-message > pre,
.flash-message > .error-detail {
  margin: 8px 0 0;
  padding: 0;
  background: transparent;
  border: 0;
}

.flash-message > strong {
  display: block;
}

/* --- Binary cache observability (Caches dashboard) ----------------------- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}

.cache-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.cache-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cache-header-title h1 {
  margin: 0;
}

.cache-section {
  margin-bottom: 20px;
}

.cache-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.cache-chart-body {
  position: relative;
  height: 280px;
}

.cache-chart-body canvas {
  max-height: 280px;
}

/* Segmented granularity switch */
.granularity-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

.granularity-toggle button {
  appearance: none;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.granularity-toggle button:last-child {
  border-right: none;
}

.granularity-toggle button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.granularity-toggle button.active {
  background: var(--text);
  color: var(--bg);
}

/* Copyable mono fields in the "How to use" panel */
.copy-label {
  display: block;
  margin: 14px 0 4px;
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.copy-label:first-child {
  margin-top: 0;
}

.copy-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.copy-field input,
.copy-field textarea {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 10px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  resize: vertical;
}

.copy-field-block {
  align-items: flex-start;
}

/* NAR inventory table cells */
.mono-trunc {
  font-family: var(--font-mono);
  font-size: 12px;
}

.nar-detail summary {
  cursor: pointer;
}

.nar-store-path {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}
