:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #18202a;
  --muted: #687384;
  --line: #d9e0e7;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #168a4a;
  --amber: #a16207;
  --red: #c2413a;
  --shadow: 0 12px 30px rgba(20, 32, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

[v-cloak] {
  display: none;
}

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

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary {
  border-color: var(--line);
  background: #fff;
}

.danger {
  background: #fff1f0;
  color: var(--red);
  border-color: #f4c7c3;
}

.danger-text {
  color: var(--red);
}

.wide {
  width: 100%;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.center-screen,
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loader {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.login-panel,
.tool-panel {
  width: min(100%, 980px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 18px;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 18px;
}

.top-actions,
.row-actions,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  overflow-x: auto;
}

.tabs button {
  border-radius: 0;
  background: transparent;
  border-bottom: 3px solid transparent;
  color: var(--muted);
}

.tabs button.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.workspace {
  display: grid;
  gap: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.form-hint {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.peer-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
}

textarea {
  resize: vertical;
  min-height: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  max-width: 420px;
  overflow-wrap: anywhere;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}

.status.healthy {
  background: #e9f8ef;
  color: var(--green);
}

.status.unhealthy {
  background: #fff1f0;
  color: var(--red);
}

.status.busy {
  background: #fff7df;
  color: var(--amber);
}

.error-line,
.notice-line {
  border-radius: 8px;
  padding: 11px 13px;
  margin: 0 0 14px;
  overflow-wrap: anywhere;
}

.error-line {
  background: #fff1f0;
  color: var(--red);
  border: 1px solid #f4c7c3;
}

.notice-line {
  background: #eef7ff;
  color: #155e9d;
  border: 1px solid #badffd;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chips span {
  border-radius: 999px;
  background: var(--surface-2);
  padding: 5px 9px;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.topology {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.node {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  background: #fff;
  font-weight: 700;
}

.link {
  color: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.healthy {
  background: var(--green);
}

.dot.unhealthy {
  background: var(--red);
}

.dot.busy {
  background: var(--amber);
}

.state-dump {
  margin: 0;
  max-height: 560px;
  overflow: auto;
  background: #101820;
  color: #d8e3ea;
  border-radius: 8px;
  padding: 16px;
  font-size: 12px;
}

@media (max-width: 920px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .row-actions {
    flex-wrap: wrap;
  }

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

/* --- jobs & host-key pinning UI --- */
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.running-text {
  color: var(--accent);
  font-weight: 600;
}

small.mono,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  display: inline-block;
}

.jobs-layout {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 2fr;
  gap: 16px;
  margin-top: 16px;
}

.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}

.job-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.job-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.job-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.job-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}

.job-dot.running {
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.job-dot.success {
  background: var(--green);
}

.job-dot.failed {
  background: var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.job-log {
  margin: 0;
  padding: 12px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.state-details {
  margin-top: 20px;
}

.state-details summary {
  cursor: pointer;
  color: var(--muted);
  padding: 6px 0;
}

@media (max-width: 820px) {
  .jobs-layout {
    grid-template-columns: 1fr;
  }
}
