:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --neutral-bg: #eef0f3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --border: #262b35;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --accent: #60a5fa;
    --ok: #4ade80; --ok-bg: #14311f;
    --bad: #f87171; --bad-bg: #3b1618;
    --warn: #fbbf24; --warn-bg: #3a2a0c;
    --info: #93c5fd; --info-bg: #16243d;
    --neutral-bg: #21262f;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 20px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
header h1 { font-size: 16px; margin: 0; letter-spacing: -0.01em; }
.header-actions { display: flex; align-items: center; gap: 8px; }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 60px auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card h2 { font-size: 14px; margin: 0 0 4px; }

.muted { color: var(--muted); }
.error { color: var(--bad); margin: 8px 0 0; }

.btn {
  font: inherit; padding: 6px 12px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 3px 9px; font-size: 12px; }

input, textarea, select {
  font: inherit; width: 100%; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

#token-form { display: flex; gap: 8px; margin-top: 12px; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-muted { background: var(--neutral-bg); color: var(--muted); }

.pipeline {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 10px;
}
.pipeline-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pipeline-name { font-weight: 600; }
.pipeline-meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.pipeline-meta code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pipeline-actions { margin-left: auto; display: flex; gap: 6px; }
.disabled-row { opacity: .55; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  background: var(--panel); color: var(--text);
  max-width: 720px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.5); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.grid .span2 { grid-column: span 2; }
.grid .check { flex-direction: row; align-items: center; gap: 7px; color: var(--text); font-size: 13px; }
.grid .check input { width: auto; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.log-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#log-dialog { max-width: 900px; }
#log-body {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; max-height: 65vh; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; margin: 0;
}

.empty { color: var(--muted); padding: 18px 0; text-align: center; }

@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .grid .span2 { grid-column: span 1; }
  .pipeline-actions { margin-left: 0; width: 100%; }
}
