/* Design tokens lifted from IC-Viewer so the two tools read as siblings. */
:root {
  --bg: #0e1116;
  --panel: #141a23;
  --panel2: #10151d;
  --border: #242d3b;
  --text: #cfd6e4;
  --dim: #8b96a8;
  --accent: #4cc2ff;
  --err: #ff5c5c;
  --warn: #ffb347;
  --info: #6aa7ff;
  --ok: #3fd68f;
  --major: #1b9c85;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 system-ui, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button {
  background: #1b2330;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font: inherit;
}
button:hover { background: #232e40; border-color: #35425a; }
button.primary { background: #1c4a6b; border-color: #2a6b9e; }
button.primary:hover { background: #235a84; }
button.danger { background: #4a1e1e; border-color: #7a3030; }
button.danger:hover { background: #5a2626; }
button.linkish { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; font: inherit; }
button:disabled { opacity: 0.4; cursor: default; }
button.small { padding: 1px 7px; font-size: 11.5px; }

input, select, textarea {
  background: #1b2330;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 6px;
  font: inherit;
}
input[type="number"] { font-family: var(--mono); width: 100px; }
input[type="checkbox"] { accent-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 12px; width: 100%; }
label.ctl { display: flex; align-items: center; gap: 6px; color: var(--dim); }

.mono { font-family: var(--mono); }
.dim { color: var(--dim); }
.pad { padding: 8px 10px; }
.nowrap { white-space: nowrap; }

/* ---------- chrome ---------- */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: none;
  min-height: 44px;
}
#brand { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; overflow: hidden; }
#app-title { font-weight: 700; letter-spacing: 0.04em; }
#conn-summary { overflow: hidden; text-overflow: ellipsis; }
#topbar-controls { display: flex; align-items: center; gap: 10px; flex: none; }

#token-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #4a3a1e;
  border-bottom: 1px solid #7a5f30;
  color: #ffe9c9;
}
#token-bar[hidden] { display: none; }

#banner {
  padding: 6px 12px;
  background: #4a1e1e;
  border-bottom: 1px solid #7a3030;
  color: #ffd9d9;
  font-weight: 600;
}
#banner[hidden] { display: none; }

#layout {
  flex: 1;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 0;
}

.panel { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }

#sidenav {
  padding: 8px 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
#sidenav a {
  display: block;
  padding: 5px 14px;
  color: var(--text);
  text-decoration: none;
}
#sidenav a:hover { background: #1a2434; }
#sidenav a.active { background: #1c2a3d; border-right: 2px solid var(--accent); color: #fff; }
.nav-head {
  padding: 10px 14px 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}
#watchlist-nav a { font-size: 12px; color: var(--dim); padding: 3px 14px; }
#watchlist-nav a:hover { color: var(--text); }

#content { border-right: none; overflow-y: auto; }
.page-body { padding: 0 0 40px; }

#bottombar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
}
#footer-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sse-state { margin-left: auto; }

/* ---------- shared bits ---------- */

.section { border-bottom: 1px solid var(--border); }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 3;
}
.section-head h2 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.section-body { padding: 10px 12px; }

table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
table.grid th {
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.grid td { padding: 4px 8px 4px 0; border-bottom: 1px solid #1b2230; vertical-align: top; }
table.grid td.num, table.grid th.num { text-align: right; font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
table.grid tr:hover td { background: #161e2a; }
table.grid tr.clickable { cursor: pointer; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }
.dot.warn { background: var(--warn); }
.dot.info { background: var(--info); }

.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 10.5px;
  font-family: var(--mono);
  border: 1px solid var(--border);
  color: var(--dim);
  white-space: nowrap;
}
.badge.major { color: #9ef0dc; border-color: #1b9c85; background: rgba(27, 156, 133, 0.12); }
.badge.notice { color: #a8c8f0; border-color: #3b7dd8; background: rgba(59, 125, 216, 0.12); }
.badge.info { color: var(--dim); }
.badge.tier-ue { color: #e8c98a; border-color: #8a6d3b; }
.badge.tier-unity { color: #b7e0ff; border-color: #3d6e8a; }
.badge.add { color: #9ef0dc; }
.badge.del { color: #ffb3b3; }
.badge.mod { color: #ffe9b3; }

.thumb { width: 92px; height: 43px; object-fit: cover; border-radius: 3px; border: 1px solid var(--border); display: block; background: #0a0d12; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; font-size: 12px; }
.kv .k { color: var(--dim); white-space: nowrap; }
.kv .v { font-family: var(--mono); font-size: 11.5px; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

pre.payload {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-family: var(--mono);
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  margin: 6px 0;
}

.expandable { cursor: pointer; }
.expandable .chev { color: var(--dim); display: inline-block; width: 12px; }
details.plain { border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; margin: 4px 0; }
details.plain summary { cursor: pointer; color: var(--dim); }

.empty { color: var(--dim); padding: 14px 12px; font-size: 12px; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.filters input[type="text"], .filters input[type="search"] { width: 200px; }

.toast {
  position: fixed;
  bottom: 40px;
  right: 16px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 12px;
  z-index: 50;
  max-width: 420px;
}
.toast.error { border-left-color: var(--err); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 30px; height: 16px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer;
  background: #1b2330; border: 1px solid var(--border); border-radius: 9px;
  transition: 0.15s;
}
.switch .track::before {
  content: ""; position: absolute; height: 10px; width: 10px; left: 2px; top: 2px;
  background: var(--dim); border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .track { background: #1c4a6b; border-color: #2a6b9e; }
.switch input:checked + .track::before { transform: translateX(14px); background: var(--accent); }
