:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fa;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: #1769aa;
  color: white;
  padding: 10px 14px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.secondary {
  background: #edf1f5;
  color: #405064;
}

button.danger {
  background: #fdecea;
  color: #a33d2a;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  background: #1769aa;
  color: white;
  padding: 10px 14px;
  text-decoration: none;
}

.button.secondary {
  background: #edf1f5;
  color: #405064;
}

input,
select {
  width: 100%;
  border: 1px solid #cad3df;
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid #dde4ee;
  background: white;
}

.brand {
  color: #17202a;
  font-weight: 700;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

nav a,
.link-button,
.secondary-link {
  color: #405064;
  text-decoration: none;
  background: transparent;
  padding: 0;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

h2 {
  font-size: 18px;
}

p {
  color: #657386;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.login-panel {
  background: white;
  border: 1px solid #dde4ee;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f7;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack label span {
  display: block;
  color: #405064;
  font-size: 13px;
  margin-bottom: 6px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.apply-all-row {
  margin-top: 12px;
}

.message {
  min-height: 20px;
  color: #a33d2a;
}

.message.ok {
  color: #287a4d;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  border-bottom: 1px solid #edf1f5;
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #657386;
  font-size: 13px;
  font-weight: 600;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid #edf1f5;
  border-radius: 8px;
  padding: 12px;
}

.run-item {
  padding: 10px 12px;
}

.item strong {
  display: block;
  margin-bottom: 4px;
}

.meta,
.kv-list {
  color: #657386;
  font-size: 13px;
}

.meta.danger {
  color: #a33d2a;
}

.compact-item {
  padding: 10px 12px;
}

.row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.row-actions button,
td button {
  padding: 7px 10px;
}

.row-actions button {
  min-height: 34px;
}

.settings-collapsible:not(.open) {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.summary-grid div {
  border: 1px solid #edf1f5;
  border-radius: 8px;
  padding: 10px;
}

.summary-grid span {
  display: block;
  color: #657386;
  font-size: 12px;
}

.summary-grid strong {
  font-size: 20px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 180px) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: #657386;
  font-size: 13px;
}

.pager button {
  padding: 7px 10px;
}

.log-item {
  border-left: 3px solid #cad3df;
}

.kv-list div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #edf1f5;
  padding: 8px 0;
}

.actions,
.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.actions.compact {
  align-items: center;
  margin-top: 10px;
}

.inline-form input {
  min-width: 260px;
}

.inline-form input[type="number"] {
  min-width: 130px;
  width: 130px;
}

.settings-form {
  margin-top: 12px;
  border-top: 1px solid #edf1f5;
  padding-top: 12px;
}

.display-name-form {
  display: grid;
  grid-template-columns: minmax(120px, 180px) auto minmax(70px, 1fr);
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.display-name-form input {
  padding: 7px 9px;
}

.display-name-form button {
  padding: 7px 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.settings-grid label span {
  display: block;
  color: #657386;
  font-size: 12px;
  margin-bottom: 4px;
}

.settings-grid input,
.settings-grid select {
  padding: 8px 10px;
}

.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf1f5;
  color: #405064;
  font-size: 12px;
}

.status.running,
.status.queued,
.status.pause_requested {
  background: #e3f2fd;
  color: #1769aa;
}

.status.completed {
  background: #e6f4ea;
  color: #287a4d;
}

.status.failed,
.status.needs_attention,
.status.cancel_requested,
.status.cancelled {
  background: #fdecea;
  color: #a33d2a;
}

.status.paused {
  background: #f1f5f9;
  color: #405064;
}

@media (max-width: 760px) {
  .topbar,
  .section-head,
  .head-actions,
  .actions,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar,
  .display-name-form,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .row-head,
  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  nav {
    width: 100%;
    justify-content: space-between;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }
}
