@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }
body, input, button, select, textarea {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
html, body, #app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

#graph-view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

#graph-canvas {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: block;
  background: #fff;
}

#graph-canvas svg {
  width: 100vw !important;
  height: 100vh !important;
  display: block;
}
.hidden { display: none !important; }
#app { position: relative; width: 100vw; height: 100vh; overflow: hidden; }
#graph-view { position: absolute; inset: 0; z-index: 1; }
#graph-canvas { position: absolute; inset: 0; background: #fff; }

#topbar-layer {
  position: absolute;
  top: 8px;
  left: 0;
  width: 100%;
  z-index: 30;
  pointer-events: none;
}
#search-shell {
  width: min(760px, calc(100vw - 48px));
  margin: 0 auto;
  pointer-events: all;
}
#search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
#search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
#search-input-wrap:focus-within {
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26,115,232,.15);
}
#search-icon { color: #aaa; font-size: 14px; user-select: none; }
#search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  background: transparent;
  min-width: 0;
}
#search-input::placeholder { color: #aaa; }
#search-clear {
  border: none;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 20px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}
#search-clear:hover { background: #f5f5f5; }

#clear-graph-btn, #sample-btn {
  height: 36px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  font-size: 12px;
  color: #555;
  white-space: nowrap;
}
#clear-graph-btn:hover, #sample-btn:hover { background: #f5f5f5; }

#search-dropdown {
  margin-top: 8px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.16);
  overflow: hidden;
  max-height: 520px;
}
.s-tabs {
  display: flex;
  gap: 4px;
  padding: 0 8px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
  position: sticky;
  top: 0;
}
.s-tab {
  padding: 8px 10px;
  font-size: 11px;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.s-tab.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
  font-weight: 600;
}
.s-badge {
  margin-left: 4px;
  background: #eee;
  border-radius: 999px;
  padding: 1px 5px;
  font-size: 10px;
}
.s-group {
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}
.s-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid #f5f5f5;
  font-size: 12px;
}
.s-row:last-child { border-bottom: none; }
.s-row:hover { background: #f9f9f9; }
.s-kind {
  min-width: 72px;
  font-size: 11px;
  font-weight: 600;
  color: #555;
}
.s-label {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: 10px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.s-chain { font-size: 11px; color: #aaa; }
.s-add {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffd400;
  color: #ffd400;
  background: none;
  cursor: pointer;
  font-weight: bold;
}
.s-add:hover { background: #ffd400; color: #fff; }
.s-add.done {
  border-color: #ccc;
  color: #ccc;
  cursor: default;
}
.s-empty, .s-loading {
  padding: 14px 12px;
  text-align: center;
  font-size: 12px;
  color: #888;
}

#details-panel {
  position: absolute;
  top: 68px;
  left: 0;
  bottom: 0;
  width: 520px;
  min-width: 280px;
  max-width: calc(100vw - 100px);
  background: #fff;
  border-right: 1px solid #e0e0e0;
  z-index: 20;
  box-shadow: 6px 0 20px rgba(0,0,0,0.08);
}
#details-content {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 10px;
}
#resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
}

#details-content h2 {
  margin: 0 0 6px;
  font-size: 15px;
}
#details-content h3 {
  margin: 10px 0 4px;
  font-size: 13px;
}
#details-content p {
  margin: 2px 0;
  line-height: 1.45;
}
#details-content .mono {
  font-family: monospace;
  word-break: break-all;
}
.card {
  border: 1px solid #ececec;
  background: #fafafa;
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px;
}
.cp, .tx-chip, .tx-chip2, .acp {
  cursor: pointer;
  border-radius: 4px;
}
.cp:hover, .acp:hover { background: #fff3cd; }
.ok { background: #d4edda !important; }
.stat-grid { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.stat-box { flex: 1; min-width: 100px; background: #f7f7f7; border-radius: 6px; padding: 10px 12px; }
.stat-label { font-size: 10px; color: #999; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.stat-val { font-size: 20px; font-weight: 700; color: #111; line-height: 1.1; }
.stat-val.mono { font-family: monospace; font-size: 15px; font-weight: 600; }
.stat-sub { font-size: 12px; color: #555; margin-top: 3px; font-weight: 500; }
.tabs { display: flex; border-bottom: 2px solid #eee; margin: 8px 0 0; }
.tab {
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #666;
  user-select: none;
}
.tab.active {
  border-bottom: 2px solid #ffd400;
  color: #111;
  font-weight: 500;
}
.tab-content { display: none; padding: 8px 0; }
.tab-content.active { display: block; }

.add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffd400;
  color: #ffd400;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.1s;
}
.add-btn:hover { background: #ffd400; color: #fff; }
.add-btn.added {
  border-color: #aaa !important;
  color: #aaa !important;
  background: none !important;
  cursor: default;
  pointer-events: none;
}
.addr-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f0;
}
.addr-row input[type=checkbox] {
  margin-top: 2px;
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: #1a73e8;
}
.addr-row input[type=checkbox]:disabled { cursor: default; opacity: 0.5; }
.addr-text b { font-size: 11px; font-family: monospace; word-break: break-all; }
.addr-val { font-size: 11px; color: #555; }
.addr-extra { font-size: 11px; margin-top: 2px; }

.table-clean {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table-clean th {
  text-align: left;
  font-size: 11px;
  color: #888;
  padding: 4px 6px;
  font-weight: 600;
  border-bottom: 2px solid #eee;
}
.table-clean td {
  padding: 5px 6px;
  vertical-align: middle;
  border-bottom: 1px solid #f5f5f5;
}
.table-clean .right { text-align: right; white-space: nowrap; }
.cluster-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #0047ab;
}
.cluster-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0047ab;
  display: inline-block;
}
.cluster-dot.gray { background: #aaa; }
.empty { font-size: 12px; color: #aaa; padding: 8px 0; }

.tx-chip2 {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: monospace;
  font-size: 10px;
  color: #0047ab;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 5px;
  background: #f0f4ff;
  border: 1px solid #d0d9f8;
  transition: background .12s;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}
.tx-chip2:hover { background: #e0ebff; }
.tx-chip2.ok { background: #d4edda !important; color: #1a7a3a; border-color: #a8d5b5; }

.tr-sort-btn, .cp-sort-btn {
  cursor: pointer;
  color: #aaa;
  font-size: 10px;
  margin-left: 3px;
  user-select: none;
}
.tr-sort-btn:hover, .tr-sort-btn.on, .cp-sort-btn:hover, .cp-sort-btn.on { color: #1a73e8; }

.graph-tooltip table {
  width: 100%;
  border-collapse: collapse;
}
.graph-tooltip td { vertical-align: top; }
/* Fix address truncation */
#details-content .mono {
  word-break: normal;
}
#details-content {
  overflow-x: hidden;
}

.tx-chip2 {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
  background: #e8f0fe;
  color: #1a73e8;
  font-family: monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
}
