:root {
  color-scheme: dark;
  --background: #080b0d;
  --surface: #0e1316;
  --surface-raised: #12191d;
  --border: #263239;
  --border-strong: #3a4951;
  --text: #e8eef1;
  --muted: #84939b;
  --dim: #56646b;
  --accent: #23c4d7;
  --accent-dark: #092e34;
  --success: #43c987;
  --warning: #e6b450;
  --danger: #ef6b73;
  --info: #61a9f5;
  --radius: 8px;
  --sans: Geist, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--background);
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.skip-link {
  position: fixed;
  z-index: 50;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  border-radius: var(--radius);
  background: var(--accent);
  color: #041012;
  padding: 8px 12px;
  font-weight: 800;
}

.skip-link:focus {
  transform: none;
}

.shell {
  width: min(1840px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 20px 20px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand-block,
.sync-block,
.health-cell,
.input-row,
.panel-heading,
.log-controls,
.log-meta,
footer {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.brand-block p,
.panel-heading .section-code,
footer,
.health-title,
.health-time,
.log-meta,
label,
#interval-hint {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.brand-block p {
  margin-top: 4px;
  letter-spacing: 0.03em;
  text-transform: none;
}

.sync-block {
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
}

.auth-button {
  border-color: var(--accent);
  background: var(--accent-dark);
  color: var(--accent);
}

.auth-button:hover {
  background: var(--accent);
  color: #041012;
}

.profile-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  max-width: 240px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.profile-link:hover { color: var(--accent); }

.profile-avatar,
.profile-fallback {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}

.profile-avatar { object-fit: cover; }

.profile-fallback {
  display: grid;
  place-items: center;
  background: var(--accent-dark);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
}

#profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-state {
  color: var(--warning);
}

.connection-state.online {
  color: var(--success);
}

.connection-state.offline {
  color: var(--danger);
}

.health-strip {
  min-height: 48px;
  display: grid;
  grid-template-columns: 140px repeat(3, minmax(150px, 1fr)) auto;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}

.health-title,
.health-time {
  display: flex;
  align-items: center;
}

.health-cell {
  gap: 8px;
  border-left: 1px solid var(--border);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
}

.health-cell samp {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
}

.health-cell.healthy .health-dot {
  background: var(--success);
}

.health-cell.down .health-dot {
  background: var(--danger);
}

.health-time {
  justify-content: flex-end;
  padding-left: 18px;
}

.error-banner {
  margin-top: 12px;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: #271216;
  color: #ffb2b7;
  padding: 6px 8px 6px 14px;
}

.error-banner:not([hidden]) {
  display: flex;
}

.operator-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(340px, 1fr);
  gap: 12px;
  padding-top: 12px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.overview {
  padding: 18px;
}

.settings {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2 {
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.compact-heading {
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}

.compact-heading h2 {
  font-size: 16px;
}

.metric-total {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(76px, 1fr));
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.metrics div {
  min-width: 0;
  border-right: 1px solid var(--border);
  padding: 10px 12px;
}

.metrics div:last-child {
  border-right: 0;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metrics output {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
}

.active-job {
  min-height: 46px;
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.active-job span {
  color: var(--muted);
  font-size: 11px;
}

.active-job strong,
.active-job samp {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-job strong {
  font-family: var(--mono);
  font-size: 12px;
}

.active-job samp {
  color: var(--accent);
  font-size: 10px;
}

form {
  margin-top: 18px;
}

label {
  display: block;
  margin-bottom: 8px;
}

.input-row {
  align-items: stretch;
  gap: 8px;
}

input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #090d0f;
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--mono);
}

#interval-submit {
  border-color: var(--accent);
  background: var(--accent);
  color: #041012;
  white-space: nowrap;
}

#interval-hint {
  margin-top: 9px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-transform: none;
}

.queue {
  min-height: 400px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--surface-raised);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

th:nth-child(1) { width: 112px; }
th:nth-child(2) { width: 130px; }
th:nth-child(4) { width: 132px; }
th:nth-child(5) { width: 150px; }

tbody tr[data-job-id] {
  cursor: pointer;
}

tbody tr[data-job-id]:hover,
tbody tr.selected {
  background: #101c20;
}

tbody tr.active-row td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

td {
  color: #c9d2d6;
  font-size: 11px;
}

td code,
td time,
.request-cell,
.files-cell {
  font-family: var(--mono);
  font-size: 10px;
}

.files-cell {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-badge.running,
.status-badge.waiting {
  border-color: var(--accent);
  color: var(--accent);
}

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

.status-badge.failed,
.status-badge.blocked_unlimited {
  border-color: var(--danger);
  color: var(--danger);
}

.status-badge.queued {
  border-color: var(--warning);
  color: var(--warning);
}

.status-badge.neutral {
  color: var(--muted);
}

.empty-state,
.detail-placeholder {
  min-height: 210px;
  place-content: center;
  text-align: center;
  color: var(--muted);
  padding: 30px;
}

.empty-state:not([hidden]) {
  display: grid;
}

.empty-state strong {
  color: var(--text);
  font-size: 15px;
}

.empty-state span {
  margin-top: 6px;
  font-size: 11px;
}

.detail {
  grid-row: span 1;
}

.detail-body {
  padding: 14px;
}

.detail-id {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
}

.detail-section {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.detail-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-section pre,
.detail-value {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.detail-section pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #090d0f;
  color: #c7d2d7;
  padding: 10px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.55;
}

.detail-grid {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
  font-size: 10px;
}

.detail-grid dt {
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
  font-family: var(--mono);
}

.file-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list li {
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 9px;
}

.error-block {
  border: 1px solid #5a2930;
  border-radius: var(--radius);
  background: #211014;
  color: #ffadb3;
  padding: 10px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
}

.retry-button {
  width: 100%;
  margin-top: 14px;
  border-color: var(--warning);
  color: var(--warning);
}

.logs {
  grid-column: 1 / -1;
}

.logs-heading {
  flex-wrap: wrap;
}

.log-controls {
  gap: 8px;
}

.segmented {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid var(--border-strong);
  border-radius: 0;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button[aria-selected="true"] {
  background: var(--accent-dark);
  color: var(--accent);
}

.secondary-button {
  background: transparent;
}

.log-meta {
  justify-content: space-between;
  gap: 14px;
  min-height: 36px;
  border-bottom: 1px solid var(--border);
  padding: 7px 14px;
  text-transform: none;
}

.log-meta samp {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#log-output {
  height: min(38vh, 440px);
  min-height: 260px;
  overflow: auto;
  margin: 0;
  background: #070a0b;
  color: #aebdc4;
  padding: 14px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.55;
  white-space: pre-wrap;
}

footer {
  min-height: 48px;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.loading-row td,
.loading-box,
.loading-state {
  color: var(--dim);
}

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

  .logs {
    grid-column: auto;
  }

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

  .health-title,
  .health-time {
    display: none;
  }

  .health-cell:first-of-type {
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 0 10px 12px;
  }

  .topbar {
    min-height: 68px;
  }

  .brand-block p,
  .connection-state {
    display: none;
  }

  .health-cell {
    min-width: 0;
    display: grid;
    grid-template-columns: 8px 1fr;
    gap: 5px;
    padding: 8px;
  }

  .health-cell samp {
    grid-column: 2;
    margin-left: 0;
  }

  .operator-grid {
    gap: 10px;
    padding-top: 10px;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .metrics div {
    border-bottom: 1px solid var(--border);
  }

  .active-job {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .table-wrap {
    max-height: 520px;
  }

  table {
    min-width: 760px;
  }

  .logs-heading,
  .log-controls {
    align-items: stretch;
  }

  .log-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .segmented {
    flex: 1;
  }

  .segmented button {
    flex: 1;
  }

  #log-output {
    height: 46vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
