:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7fb;
  color: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: #f4f7fb;
}

a {
  color: #2563eb;
  text-decoration: none;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.9em;
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  background: #111827;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #9ca3af;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  padding: 10px 12px;
  border-radius: 8px;
  color: #d1d5db;
  background: transparent;
}

nav a:hover {
  background: #1f2937;
  color: #fff;
}

.sidebar-note {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #0b1220;
  font-size: 13px;
  color: #9ca3af;
}

.sidebar-note strong {
  color: #fff;
}

main {
  padding: 28px;
  display: grid;
  gap: 24px;
}

.topbar,
.section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.06);
}

.topbar {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.topbar p {
  margin-top: 6px;
  color: #6b7280;
}

.section {
  overflow: hidden;
}

.section-head {
  min-height: 58px;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.devices-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.hub-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.hub-tables {
  padding: 0 20px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hub-card {
  border-color: #dbeafe;
  background: #fbfdff;
}

.bind-intro {
  padding: 16px 20px 0;
  display: grid;
  gap: 4px;
  color: #4b5563;
}

.bind-intro strong {
  color: #111827;
}

.bind-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.bind-card {
  min-height: 150px;
  padding: 18px;
  border: 2px solid #2563eb;
  border-radius: 10px;
  background: #f8fbff;
  display: grid;
  gap: 16px;
  align-content: space-between;
}

.bind-card p {
  margin-top: 6px;
  color: #4b5563;
}

.bind-downloads {
  padding: 0 20px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-weight: 700;
}

.device-card,
.panel-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}

.device-card {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.device-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.device-name {
  font-weight: 700;
}

.device-meta {
  margin-top: 4px;
  color: #6b7280;
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  padding: 10px;
  border-radius: 8px;
  background: #f9fafb;
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
}

.button:hover {
  background: #1d4ed8;
}

.button.secondary {
  background: #eef2ff;
  color: #3730a3;
}

.button.secondary:hover {
  background: #e0e7ff;
}

.button.danger {
  background: #fee2e2;
  color: #991b1b;
}

.button.danger:hover {
  background: #fecaca;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
}

.pill.online {
  background: #dcfce7;
  color: #166534;
}

.pill.offline {
  background: #fee2e2;
  color: #991b1b;
}

.pill.warning {
  background: #fef3c7;
  color: #92400e;
}

.setup-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.panel-card {
  padding: 18px;
}

.panel-card.danger {
  border-color: #fecaca;
  background: #fff7f7;
}

.check-list,
.steps {
  margin: 0;
  padding-left: 20px;
  color: #4b5563;
}

.check-list li,
.steps li {
  margin: 8px 0;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f9fafb;
  color: #6b7280;
  font-weight: 700;
}

td pre {
  max-width: 520px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #4b5563;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .devices-grid,
  .hub-grid,
  .hub-tables,
  .bind-grid,
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(17 24 39 / 0.62);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 50px rgb(15 23 42 / 0.3);
}

.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.modal-head p {
  margin-top: 4px;
  color: #6b7280;
  font-size: 13px;
}

.qr-wrap {
  padding: 24px;
  display: grid;
  place-items: center;
}

.qr-wrap img {
  width: min(320px, 100%);
  height: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.qr-payload {
  margin: 0;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #4b5563;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}
