:root {
  --bg: #0f1419;
  --panel: #182029;
  --panel2: #1f2a35;
  --line: #2c3a48;
  --text: #e6edf3;
  --muted: #8b9bab;
  --accent: #3b9eff;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.brand span { color: var(--accent); font-weight: 500; }

nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav[hidden], #toast[hidden] { display: none; }
.navbtn { background: transparent; border: 1px solid transparent; color: var(--muted); }
.navbtn.active { color: var(--text); border-color: var(--line); background: var(--panel2); }

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

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 48px auto; }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card h3 { margin: 18px 0 8px; font-size: 15px; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

button {
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font: inherit; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--bad); border-color: var(--bad); }

.err { color: var(--bad); margin-top: 10px; min-height: 1em; }

.secret {
  background: var(--bg); border: 1px dashed var(--warn); border-radius: 6px; padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px;
  word-break: break-all; user-select: all;
}
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; }
.qr { background: #fff; padding: 8px; border-radius: 6px; width: 236px; height: 236px; }
.qr img { width: 220px; height: 220px; display: block; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 10; overflow: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; width: 100%; max-width: 520px;
}

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 6px; z-index: 20;
}
#toast.bad { border-color: var(--bad); color: var(--bad); }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .codes { grid-template-columns: 1fr; }
}

.mt { margin-top: 14px; }
.ml { margin-left: 8px; }
.pre { white-space: pre-wrap; }
label.inline { display: inline; margin: 0; }
input[type=checkbox] { width: auto; }
.nowrap { white-space: nowrap; }

/* bridge page */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 17px; font-weight: 600; margin-top: 2px; word-break: break-word; }
.boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.boxcard { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 12px; }
.boxcard.ok { border-left-color: var(--ok); }
.boxcard.warn { border-left-color: var(--warn); }
.boxcard.bad { border-left-color: var(--bad); }
.boxtitle { font-size: 20px; font-weight: 700; line-height: 1.15; word-break: break-word; }
.boxaddr { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }

/* activity */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; align-items: end; }
.filters .f label { margin: 0 0 4px; }
.filters .btnrow { display: flex; gap: 8px; }
.sortbtn { background: transparent; border: 0; padding: 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.sortbtn:hover { color: var(--text); }
a.linkish { color: var(--accent); cursor: pointer; }
a.linkish:hover { text-decoration: underline; }


/* center cell text vertically, so rows with buttons or pills line up */
th, td { vertical-align: middle; }
td > .row, td > .btns { margin-top: 0; }

/* help button and popup */
.helpbtn {
  width: 28px; height: 28px; padding: 0; border-radius: 50%; align-self: center;
  margin-left: 6px; font-weight: 700; font-size: 14px; line-height: 1;
  color: var(--accent); border-color: var(--accent); background: transparent;
}
.helpbtn:hover { background: var(--accent); color: #fff; }
.modal-box.helpbox { max-width: 640px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; padding: 0; }
.helphead { padding: 16px 20px 10px; border-bottom: 1px solid var(--line); }
.helphead h2 { margin: 0; font-size: 18px; }
.helpbody { padding: 4px 20px 8px; overflow-y: auto; flex: 1; color-scheme: dark; }
.helpbody h3 { margin: 16px 0 6px; font-size: 15px; color: var(--accent); }
.helpbody p { margin: 6px 0; }
.helpdl { margin: 6px 0; }
.helpdl dt { font-weight: 600; margin-top: 10px; }
.helpdl dd { margin: 2px 0 0; color: var(--muted); }
.helpfoot { margin: 0; padding: 12px 20px; border-top: 1px solid var(--line); justify-content: flex-end; }
