/* Git Sync Bridge admin console — dark ink-blue "two remotes, one bridge" theme. */

:root {
  --bg: #0b1220;
  --panel: #121b2d;
  --panel-2: #17223a;
  --edge: #24314e;
  --edge-light: #33436b;
  --text: #e6ecf7;
  --muted: #8b99b8;
  --faint: #5c6a8c;

  --gh: #c9d6e8;   /* GitHub pole: silver */
  --gl: #fc6d26;   /* GitLab pole: brand orange */

  --ok: #3fb68b;
  --err: #e5534b;
  --warn: #d4a72c;
  --info: #5b8dd9;

  --font-ui: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", Consolas, "Malgun Gothic", monospace;

  --radius: 10px;
  --shadow: 0 8px 24px rgba(4, 8, 18, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 500px at 50% -220px, #16223c 0%, transparent 65%),
    var(--bg);
  color: var(--text);
  font: 400 14px/1.6 var(--font-ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 22px; }
.brand-name { font: 600 15px var(--font-mono); letter-spacing: 0.02em; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.health { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.health.ok .health-dot { background: var(--ok); box-shadow: 0 0 8px rgba(63, 182, 139, 0.6); }
.health.bad .health-dot { background: var(--err); }

/* ---------- layout ---------- */

.app {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.foot {
  display: flex;
  justify-content: space-between;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 24px 22px;
  color: var(--faint);
  font-size: 12px;
  border-top: 1px solid var(--edge);
}
.foot-links { display: flex; gap: 14px; }
.foot-links a { color: var(--faint); }
.foot-links a:hover { color: var(--muted); }

.eyebrow {
  font: 600 11px var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 4px;
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

section { margin-bottom: 26px; }
section > h2 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--edge-light);
  background: var(--panel-2);
  color: var(--text);
  font: 500 13px var(--font-ui);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--info); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: #234069; border-color: #35578a; }
.btn-primary:hover { background: #2a4c7d; border-color: #4a6ea6; }

.btn-danger { color: #f0a9a5; }
.btn-danger:hover { border-color: var(--err); }

.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: var(--edge-light); color: var(--text); }

/* ---------- bridge (signature) ---------- */

.bridge {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  --line-c: var(--faint);
}

.pole { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 84px; padding-top: 2px; }
.node { width: 11px; height: 11px; border-radius: 50%; }
.pole-gh .node { background: var(--gh); box-shadow: 0 0 10px rgba(201, 214, 232, 0.4); }
.pole-gl .node { background: var(--gl); box-shadow: 0 0 10px rgba(252, 109, 38, 0.45); }
.pole-name { font: 600 11px var(--font-mono); letter-spacing: 0.08em; color: var(--muted); }
.pole-host {
  font: 400 11px var(--font-mono);
  color: var(--faint);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line {
  flex: 1;
  position: relative;
  height: 15px;
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.line::before {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, var(--line-c) 0 7px, transparent 7px 15px);
  opacity: 0.75;
}
.bridge.running .line::before { animation: flow 0.8s linear infinite; opacity: 1; }
.bridge.dir-rev.running .line::before { animation-direction: reverse; }
@keyframes flow { to { background-position: 15px 0; } }

.arrow {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 0 10px;
  font: 600 12px var(--font-mono);
  color: var(--line-c);
  line-height: 20px;
}

.bridge.st-success { --line-c: var(--ok); }
.bridge.st-failed { --line-c: var(--err); }
.bridge.st-conflict { --line-c: var(--warn); }
.bridge.st-no_change, .bridge.st-skipped { --line-c: var(--muted); }
.bridge.running { --line-c: var(--info); }

.bridge-lg .node { width: 14px; height: 14px; }
.bridge-lg .pole-host { max-width: 240px; font-size: 12px; }
.bridge-lg .pole-name { font-size: 12px; }

/* ---------- cards / dashboard ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: border-color 0.15s, transform 0.15s;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--edge-light); transform: translateY(-1px); }
.card.off { opacity: 0.55; }

.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-name { font-size: 15px; font-weight: 650; }
.chip {
  display: inline-block;
  font: 500 11px var(--font-mono);
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 1px 9px;
  margin-left: 8px;
  vertical-align: 1px;
}
.card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.card-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; }
.card-actions { display: flex; gap: 7px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 600 11.5px var(--font-mono);
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid;
}
.badge::before { content: "●"; font-size: 8px; }
.badge-success { color: var(--ok); border-color: rgba(63, 182, 139, 0.4); }
.badge-failed { color: var(--err); border-color: rgba(229, 83, 75, 0.4); }
.badge-conflict { color: var(--warn); border-color: rgba(212, 167, 44, 0.4); }
.badge-no_change, .badge-skipped { color: var(--muted); border-color: var(--edge-light); }
.badge-off { color: var(--faint); border-color: var(--edge); }
.badge-on { color: var(--ok); border-color: rgba(63, 182, 139, 0.4); }
.badge-run { color: var(--info); border-color: rgba(91, 141, 217, 0.5); }

/* ---------- bulk sync progress ---------- */

.bulk-panel { margin-bottom: 16px; }
.bulk-panel.has-failures { border-color: rgba(229, 83, 75, 0.45); }
.bulk-panel h2 { font-size: 15px; font-weight: 650; }

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--edge);
  overflow: hidden;
}
.progress-bar {
  display: block;
  height: 100%;
  background: var(--info);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress.live .progress-bar {
  background: repeating-linear-gradient(
    135deg, var(--info) 0 10px, #4a7cc4 10px 20px
  );
  background-size: 28px 100%;
  animation: progress-stripes 0.9s linear infinite;
}
@keyframes progress-stripes { to { background-position: 28px 0; } }

.bulk-now { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.bulk-now a { font-family: var(--font-mono); }

.bulk-fails { margin-top: 14px; }
.bulk-fails .wh-title { margin-bottom: 8px; }
.bulk-fails td.msg { max-width: 460px; word-break: break-word; }
.bulk-fails details { margin-top: 6px; }
.bulk-fails summary { cursor: pointer; font-size: 11.5px; color: var(--faint); }
.bulk-fails pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 6px;
  font: 400 11.5px/1.5 var(--font-mono);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- empty state ---------- */

.empty {
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--edge-light);
  border-radius: var(--radius);
}
.empty .bridge { max-width: 420px; margin: 0 auto 22px; }
.empty h2 { margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 20px; color: var(--muted); }

/* ---------- wizard ---------- */

.wizard { max-width: 860px; }

.steps { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.step { display: flex; align-items: center; gap: 8px; color: var(--faint); }
.step-num {
  font: 600 12px var(--font-mono);
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--edge-light);
  background: var(--panel);
}
.step-label { font-size: 13px; font-weight: 550; }
.step.active { color: var(--text); }
.step.active .step-num { border-color: var(--info); color: var(--info); }
.step.done { color: var(--muted); }
.step.done .step-num { border-color: var(--ok); color: var(--ok); }
.step-line { flex: 1; height: 1px; background: var(--edge); min-width: 18px; }

.wizard-body { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 20px;
}

.help {
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 12.5px;
  color: var(--muted);
}
.help h3 { margin: 0 0 8px; font-size: 13px; color: var(--text); }
.help ol { margin: 0 0 10px; padding-left: 18px; }
.help li { margin-bottom: 5px; }
.help code {
  font: 500 11.5px var(--font-mono);
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 0 5px;
  color: var(--text);
}
.help .btn { margin-top: 4px; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 550; color: var(--muted); margin-bottom: 5px; }
.field input[type="text"], .field input[type="password"], .field input[type="url"] {
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--edge-light);
  background: var(--bg);
  color: var(--text);
  font: 400 13px var(--font-mono);
}
.field input:focus { outline: none; border-color: var(--info); }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.field.invalid input { border-color: var(--err); }
.field .field-error { font-size: 11.5px; color: var(--err); margin-top: 4px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--info); width: 15px; height: 15px; }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 20px; }

.summary-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.summary-table th {
  text-align: left; color: var(--faint); font-weight: 500;
  padding: 6px 14px 6px 0; white-space: nowrap; vertical-align: top; width: 110px;
}
.summary-table td { padding: 6px 0; font-family: var(--font-mono); font-size: 12.5px; word-break: break-all; }

/* ---------- detail ---------- */

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.kv { display: flex; flex-direction: column; gap: 9px; }
.kv-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.kv-key { color: var(--faint); min-width: 110px; font-size: 12.5px; }
.kv-val { font-family: var(--font-mono); font-size: 12.5px; word-break: break-all; }

.mono { font-family: var(--font-mono); }

.copyline {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 6px 8px 6px 12px;
  margin: 6px 0 10px;
}
.copyline code {
  flex: 1;
  font: 500 12px var(--font-mono);
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.wh-block { margin-bottom: 16px; }
.wh-block:last-child { margin-bottom: 0; }
.wh-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.wh-title .node { width: 9px; height: 9px; }
.wh-steps { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.wh-steps li { margin-bottom: 3px; }
.wh-steps code {
  font: 500 11.5px var(--font-mono);
  background: var(--panel-2); border: 1px solid var(--edge);
  border-radius: 4px; padding: 0 5px; color: var(--text);
}

.callout {
  border: 1px solid rgba(212, 167, 44, 0.45);
  background: rgba(212, 167, 44, 0.07);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #e8cf8e;
  margin-top: 12px;
}
.callout.info {
  border-color: rgba(91, 141, 217, 0.45);
  background: rgba(91, 141, 217, 0.08);
  color: #a9c4ec;
}

.highlight-webhooks { border-color: var(--info) !important; box-shadow: 0 0 0 1px var(--info); }

/* ---------- relation diagnosis & seeding ---------- */

.rel-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint-inline { font-size: 11.5px; color: var(--faint); }

.rel-verdict { display: flex; align-items: center; gap: 10px; margin: 16px 0 8px; }
.rel-verdict .badge { font-size: 12.5px; padding: 3px 12px; }

.stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.stat {
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--muted);
}
.stat b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }

.seed-box {
  border: 1px solid var(--edge-light);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 14px;
  background: var(--bg);
}

.radio-row { display: flex; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }
.radio-opt {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 9px 12px;
  flex: 1;
  min-width: 220px;
  transition: border-color 0.15s;
}
.radio-opt:hover { border-color: var(--edge-light); }
.radio-opt.checked { border-color: var(--info); }
.radio-opt input { accent-color: var(--info); margin-top: 3px; }
.radio-opt .opt-desc { font-size: 11.5px; color: var(--faint); line-height: 1.5; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--edge); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left;
  font: 600 11px var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  background: var(--panel);
  padding: 9px 14px;
  border-bottom: 1px solid var(--edge);
  white-space: nowrap;
}
table.data td { padding: 8px 14px; border-bottom: 1px solid var(--edge); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data td.mono { font-size: 12px; white-space: nowrap; }
td.msg { color: var(--muted); max-width: 380px; }

.none { color: var(--faint); font-size: 13px; padding: 14px 2px; }

/* ---------- conflicts ---------- */

.conflict-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.file-chip {
  font: 500 11.5px var(--font-mono);
  background: var(--panel-2);
  border: 1px solid rgba(212, 167, 44, 0.4);
  color: #e8cf8e;
  border-radius: 6px;
  padding: 2px 8px;
}

/* ---------- edit form ---------- */

details.editor { border: 1px solid var(--edge); border-radius: var(--radius); background: var(--panel); }
details.editor summary {
  cursor: pointer;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
  list-style: none;
}
details.editor summary::before { content: "▸ "; color: var(--faint); }
details.editor[open] summary::before { content: "▾ "; }
details.editor summary:hover { color: var(--text); }
details.editor .editor-body { padding: 4px 18px 18px; border-top: 1px solid var(--edge); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; padding-top: 12px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: var(--panel-2);
  border: 1px solid var(--edge-light);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--err); color: #f0a9a5; }

.loading { color: var(--faint); padding: 40px 0; text-align: center; font-family: var(--font-mono); font-size: 13px; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .wizard-body, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .pole-host { max-width: 90px; }
  .bridge-lg .pole-host { max-width: 110px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .steps { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .bridge.running .line::before { animation: none; }
  .progress.live .progress-bar { animation: none; }
  .card, .btn, .toast, .progress-bar { transition: none; }
}
