:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #f4f6f8;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button {
  min-height: 34px;
  border: 1px solid #b8c2cc;
  border-radius: 6px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
  padding: 6px 10px;
  cursor: pointer;
}

button:hover {
  background: #eef3f7;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar,
.panel {
  background: #ffffff;
  border: 1px solid #d8e0e7;
  border-radius: 8px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 2fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 15px;
}

.muted {
  margin-top: 4px;
  color: #697989;
  font-size: 13px;
}

.status-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  border: 1px solid #e3e9ef;
  border-radius: 6px;
  padding: 8px;
  background: #f8fafc;
}

.metric span {
  display: block;
  color: #687887;
  font-size: 12px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.3;
  margin-top: 3px;
}

.metric.wide {
  grid-column: span 2;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.actions.compact {
  justify-content: flex-start;
}

.layout {
  display: grid;
  grid-template-columns: minmax(560px, 1.25fr) minmax(420px, 0.75fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border-bottom: 1px solid #e5ebf0;
  padding: 7px 6px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #526170;
  font-weight: 650;
  background: #f6f8fa;
}

.badge {
  display: inline-flex;
  min-width: 56px;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}

.badge.parent {
  background: #e4f1ff;
  color: #155a99;
}

.badge.child {
  background: #e5f7ed;
  color: #1e7140;
}

.badge.unknown {
  background: #eceff3;
  color: #526170;
}

.badge.online {
  background: #dff7e7;
  color: #166534;
}

.badge.idle {
  background: #fff3d8;
  color: #8a5a00;
}

.children-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.child-card {
  border: 1px solid #e3e9ef;
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfd;
  font-size: 13px;
}

.packet-area {
  display: grid;
  grid-template-columns: minmax(620px, 1.2fr) minmax(360px, 0.8fr);
  gap: 14px;
  margin-top: 14px;
}

.packet-log {
  height: 430px;
  overflow: auto;
  border: 1px solid #e3e9ef;
  border-radius: 6px;
  background: #0f1720;
  color: #e5eef7;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
}

.packet-row {
  display: grid;
  grid-template-columns: 92px 40px 64px minmax(120px, 1fr) 90px minmax(180px, 2fr);
  gap: 8px;
  padding: 7px 8px;
  border-bottom: 1px solid #223142;
  cursor: pointer;
}

.packet-row:hover,
.packet-row.selected {
  background: #1e2a38;
}

.packet-row.conflict {
  color: #ffd1d1;
  background: #3a161a;
}

.packet-row.error {
  color: #ffe0bd;
}

.detail pre,
#packetDetail {
  height: 430px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #e3e9ef;
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
}

@media (max-width: 980px) {
  .topbar,
  .layout,
  .packet-area {
    grid-template-columns: 1fr;
  }

  .status-grid,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .packet-row {
    grid-template-columns: 80px 36px 58px minmax(90px, 1fr);
  }

  .packet-row span:nth-child(n + 5) {
    display: none;
  }
}
