:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #dce1e8;
  --accent: #cc0000;
  --accent-strong: #a00000;
  --accent-blue: #1677ff;
  --accent-blue-strong: #0958d9;
  --success: #16803c;
  --warning: #b76e00;
  --failed: #cc0000;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 232px 1fr;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(204, 0, 0, 0.3);
}

button.secondary {
  background: #eef2f7;
  color: var(--text);
}

button.secondary:hover {
  background: #e3e8ef;
}

button.danger {
  background: #d92d20;
}

.sidebar {
  background: linear-gradient(180deg, #8b0000 0%, #1a1a2e 100%);
  color: #fff;
  padding: 22px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, #cc0000, #ff4444);
  font-weight: 800;
  font-size: 20px;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #b7c0ce;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d6dbe4;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(204, 0, 0, 0.35);
  color: #fff;
}

.shell {
  padding: 26px 30px;
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.toolbar-right {
  display: flex;
  align-items: center;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #cc0000, #1677ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
  white-space: nowrap;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 24px;
}

.toolbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table th {
  background: #f8fafc;
  color: #465366;
  font-size: 13px;
}

.table tr:last-child td {
  border-bottom: 0;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f7;
  color: #344054;
}

.badge.success {
  background: #e8f7ee;
  color: var(--success);
}

.badge.warning {
  background: #fff4d6;
  color: var(--warning);
}

.badge.failed {
  background: #ffe8e8;
  color: var(--failed);
}

.badge.running {
  background: #e9f2ff;
  color: var(--accent-strong);
}

.badge.queued {
  background: #eef2f7;
  color: #465366;
}

.muted {
  color: var(--muted);
}

.alert {
  margin-bottom: 14px;
  border: 1px solid #ffcccc;
  background: #fff5f5;
  color: #8b0000;
  border-radius: 8px;
  padding: 10px 12px;
}

.hidden {
  display: none;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.modal-inner {
  padding: 0;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

#modal-body {
  padding: 18px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  background: #eef2f7;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: #344054;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.secret-row button {
  min-width: 72px;
}

.private-key-text {
  min-height: 140px;
  font-family: Consolas, "Courier New", monospace;
}

.split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
  margin: 10px 0;
}

.progress span {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #cc0000, #1677ff);
  transition: width 0.2s ease;
}

.list {
  display: grid;
  gap: 10px;
}

.run-card,
.template-card {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.run-card:last-child,
.template-card:last-child {
  border-bottom: 0;
}

.detail {
  padding: 16px;
}

.detail h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.host-detail {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.host-detail:first-of-type {
  border-top: 0;
}

.anomaly-list {
  display: grid;
  gap: 12px;
}

.anomaly-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.anomaly-item pre {
  max-height: 140px;
}

pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #111827;
  color: #edf2f7;
  padding: 12px;
  border-radius: 8px;
  max-height: 360px;
  overflow: auto;
}

.checkbox-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row span {
  min-width: 0;
}

.checkbox-row input {
  width: auto;
}

.day-group {
  margin-bottom: 6px;
}

.day-header {
  font-size: 14px;
  color: var(--muted);
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

.run-index {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  background: rgba(204,0,0,0.08);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
  }

  .brand {
    margin: 0;
  }

  nav {
    display: flex;
  }

  .shell {
    padding: 18px 14px;
  }

  .toolbar,
  .split,
  .dashboard-grid,
  .metric-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
