 :root {
  --bg: #071127;
  --bg-2: #0c1a36;
  --panel: #0f1d3b;
  --panel-2: #13264c;
  --line: #223b74;
  --line-soft: rgba(120, 160, 255, 0.16);
  --text: #f4f7ff;
  --muted: #a6b8df;
  --muted-2: #7f95c4;
  --green: #22c55e;
  --yellow: #facc15;
  --red: #fb7185;
  --blue: #63a7ff;
  --none: #233a70;
  --chip-bg: #16284d;
  --chip-bg-soft: #132243;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html { background: radial-gradient(circle at top, #0d1f42 0%, var(--bg) 45%, #050d20 100%); }
body { margin: 0; color: var(--text); font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: transparent; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 28px 24px 48px; }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0 0 8px; font-size: 48px; line-height: 1.08; letter-spacing: -0.03em; }
.sub { margin: 0; color: var(--muted); font-size: 15px; }

button {
  appearance: none;
  background: linear-gradient(180deg, #5f9dff 0%, #2e72eb 100%);
  color: #fff;
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  min-width: 72px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(46, 114, 235, 0.28);
}
button:hover { filter: brightness(1.06); }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 22px 0 10px; }
.card, .panel { background: linear-gradient(180deg, rgba(18, 33, 66, 0.96) 0%, rgba(13, 26, 54, 0.98) 100%); border: 1px solid var(--line-soft); border-radius: 20px; box-shadow: var(--shadow); }
.card { padding: 18px 20px 16px; position: relative; overflow: hidden; }
.card::after { content: ""; position: absolute; inset: auto -30px -30px auto; width: 120px; height: 120px; border-radius: 50%; opacity: 0.25; filter: blur(10px); }
.card span { display: block; color: var(--muted); margin-bottom: 10px; font-size: 14px; font-weight: 800; letter-spacing: .02em; }
.card strong { display: block; font-size: 48px; line-height: 1; letter-spacing: -0.04em; margin-bottom: 10px; }
.card small { display: block; color: var(--muted-2); font-size: 13px; }
.card.connected { border-color: rgba(55, 214, 122, 0.25); }
.card.connected::after { background: var(--green); }
.card.recent { border-color: rgba(250, 204, 21, 0.22); }
.card.recent::after { background: var(--yellow); }
.card.accent { border-color: rgba(99, 167, 255, 0.24); }
.card.accent::after { background: var(--blue); }

.panel { padding: 18px 18px 16px; margin-top: 14px; }
.compact-panel { padding-top: 14px; padding-bottom: 14px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-header h2 { margin: 0; font-size: 34px; line-height: 1.05; letter-spacing: -0.03em; }
.subnet-header { margin-bottom: 18px; }
.subnet-meta { margin: 8px 0 0; color: var(--muted); font-size: 17px; }
.meta-strong { color: var(--text); font-weight: 800; font-size: 21px; }
.meta-divider { color: var(--muted-2); margin: 0 8px; }

.section-label { margin-top: 10px; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: #a9b7d0; }
.chip-section { margin-top: 10px; }
.compact-chip-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.chip-wrap { position: relative; display: inline-flex; }

.ip-chip {
  position: relative;
  background: linear-gradient(180deg, var(--chip-bg) 0%, var(--chip-bg-soft) 100%);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.ip-chip:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0,0,0,0.18); }

.compact-chip {
  width: 72px;
  height: 44px;
  min-width: 72px;
  max-width: 72px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.compact-chip .suffix { display: block; font-size: 20px; font-weight: 700; line-height: 1; letter-spacing: 0.02em; color: #fff; }
.compact-chip .label { display: none; }
.ip-chip.up { background: linear-gradient(180deg, #1f7a44 0%, #176236 100%); color: #fff; }
.ip-chip.warn { background: linear-gradient(180deg, #b8860b 0%, #926b08 100%); color: #fff; }
.ip-chip.down, .ip-chip.recent-chip { background: linear-gradient(180deg, #7a2f3c 0%, #612531 100%); color: #fff; }

.edit-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
  box-shadow: none;
}
.chip-wrap:hover .edit-btn { opacity: 1; transform: scale(1); }
.edit-btn:hover { background: rgba(255,255,255,0.28); }

.summary-count { margin-left: 8px; color: var(--muted); font-size: 13px; }
.fold-panel { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 16px; }
.fold-panel summary { cursor: pointer; color: var(--text); list-style: none; user-select: none; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.fold-panel summary::-webkit-details-marker { display: none; }
.fold-panel summary::before { content: '▸'; color: var(--blue); }
.fold-panel[open] summary::before { content: '▾'; }
.fold-panel[open] summary { margin-bottom: 14px; }
.muted-section { padding-top: 4px; }
.empty-note { color: var(--muted); margin: 4px 0 0; font-size: 15px; }

.heatmap-panel { margin-top: 20px; }
.heatmap-header { margin-top: 4px; margin-bottom: 12px; }
.legend { color: var(--muted); margin: 0; font-size: 14px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 6px 0 12px; }
.dot.green, .cell.green { background: var(--green); }
.dot.red, .cell.red { background: var(--red); }
.dot.none, .cell.none { background: var(--none); }
.heatmap-direction { font-size: 12px; color: #9fb0d0; margin: 0; }
.heatmap-wrap { max-height: 420px; overflow: auto; border-radius: 14px; }
.heatmap { width: 100%; border-collapse: collapse; }
.heatmap th, .heatmap td { padding: 0; min-width: 18px; height: 24px; border: 1px solid rgba(34, 59, 116, 0.45); }
.heatmap thead th { position: sticky; top: 0; background: var(--panel); color: var(--muted); padding: 6px; font-size: 12px; font-weight: 700; }
.heatmap tbody th { position: sticky; left: 0; background: var(--panel); padding: 0 10px; text-align: left; min-width: 132px; font-size: 13px; }
.heatmap tbody tr.heatmap-focus th, .heatmap tbody tr.heatmap-focus td { outline: 2px solid rgba(255, 255, 255, 0.28); outline-offset: -2px; }

@media (max-width: 960px) {
  .wrap { padding: 20px 16px 40px; }
  .topbar { align-items: stretch; flex-direction: column; }
  h1 { font-size: 34px; }
  .cards { grid-template-columns: 1fr; }
  .panel-header h2 { font-size: 28px; }
  .subnet-meta { font-size: 15px; }
  .meta-strong { font-size: 18px; }
}

.ip-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ip-name {
  font-size: 10px;
  opacity: 0.8;
  margin-top: 2px;
  white-space: nowrap;
}

.ip-chip.has-name {
  border: 1px solid rgba(255,255,255,0.2);
}