:root {
  --bg: #0b0d11;
  --bg-2: #10141b;
  --surface: #161b24;
  --surface-2: #1c2330;
  --line: #2a3342;
  --line-2: #3a4556;
  --text: #e8eef5;
  --muted: #8d99a8;
  --faint: #66707d;
  --amber: #f0b429;
  --amber-dim: #8a6914;
  --green: #3ecf8e;
  --red: #ef6b73;
  --blue: #6cb6ff;
  --warn: #f5a524;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --mono: "IBM Plex Mono", "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--amber); }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: 56px 1fr 180px;
  grid-template-columns: 200px 1fr;
  grid-template-areas:
    "top top"
    "nav main"
    "log log";
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #141922, #10141b);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 240px; }
.brand h1 { margin: 0; font-size: 15px; letter-spacing: 0.08em; font-weight: 650; text-transform: uppercase; }
.brand .tag { color: var(--amber); font-family: var(--mono); font-size: 11px; border: 1px solid var(--amber-dim); padding: 1px 6px; border-radius: 999px; }
.top-status { display: flex; align-items: center; gap: 14px; flex: 1; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }
.addr { font-family: var(--mono); font-size: 12px; color: var(--text); }
.top-actions { display: flex; gap: 8px; }

.nav {
  grid-area: nav;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav button {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 8px;
}
.nav button:hover { background: var(--surface); color: var(--text); }
.nav button.active { background: var(--surface-2); color: var(--amber); }

.main {
  grid-area: main;
  overflow: auto;
  padding: 18px 22px 28px;
}
.panel { display: none; max-width: 1100px; }
.panel.active { display: block; }
h2 { margin: 0 0 6px; font-size: 18px; font-weight: 650; }
.lead { margin: 0 0 16px; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 650; color: var(--text); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 140px; flex: 1; }
.field.grow { flex: 2; }
.field.narrow { flex: 0 0 140px; min-width: 120px; }
.field label { color: var(--muted); font-size: 12px; }
.field .hint { color: var(--faint); font-size: 11px; }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--amber-dim); }
textarea { min-height: 78px; resize: vertical; font-family: var(--mono); font-size: 12px; }
input[type="password"], input[type="text"].mono, .mono { font-family: var(--mono); }

.btn {
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { border-color: var(--amber-dim); }
.btn.primary { background: #c99214; border-color: #e0ac2a; color: #1a1304; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: #6d2d32; color: var(--red); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 13px; }
.kv span:first-child { color: var(--muted); }
.warn, .ok, .bad { font-size: 13px; }
.warn { color: var(--warn); }
.ok { color: var(--green); }
.bad { color: var(--red); }

.table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; }
td.mono, th.mono { font-family: var(--mono); }
tr:hover td { background: rgba(255,255,255,0.02); }
.chk { width: 28px; }

.logdock {
  grid-area: log;
  border-top: 1px solid var(--line);
  background: #0a0c10;
  display: flex;
  flex-direction: column;
}
.logdock header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}
#loglist {
  flex: 1;
  overflow: auto;
  margin: 0;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: #b8c0cc;
}
.log-info { color: #b8c0cc; }
.log-warn { color: var(--warn); }
.log-error { color: var(--red); }
.log-ts { color: var(--faint); margin-right: 8px; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok { color: var(--green); border-color: #1f6b4a; }
.badge.failed, .badge.reverted { color: var(--red); border-color: #6d2d32; }
.badge.skipped { color: var(--warn); border-color: #6b4e16; }
.badge.running { color: var(--blue); border-color: #355a82; }

.progress {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress > div { height: 100%; background: var(--amber); width: 0; transition: width 0.2s; }

.gate {
  max-width: 460px;
  margin: 40px auto;
}
.hidden { display: none !important; }
.linkish { background: none; border: 0; color: var(--blue); padding: 0; }

.hash a { color: var(--blue); text-decoration: none; font-family: var(--mono); font-size: 11px; }
.hash a:hover { text-decoration: underline; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.selcount { color: var(--muted); font-size: 12px; }

.callout {
  background: #1a160c;
  border: 1px solid #3d3318;
  color: #e6d5a2;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 12px;
}
.callout strong { color: var(--amber); }

.warnbar {
  grid-column: 1 / -1;
  background: #2a1c08;
  border-bottom: 1px solid #6b4e16;
  color: #f3d59a;
  padding: 8px 16px;
  font-size: 12.5px;
  line-height: 1.55;
}
.warnbar strong { color: #f0b429; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.app {
  grid-template-rows: 56px auto 1fr 180px;
  grid-template-areas:
    "top top"
    "warn warn"
    "nav main"
    "log log";
}
.warnbar { grid-area: warn; }
label.btn { display: inline-flex; align-items: center; }
#gate { display: block; margin-bottom: 16px; }
