:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #172033;
  --muted: #667085;
  --border: #dde3ee;
  --blue: #1457d9;
  --blue-dark: #0f43aa;
  --green: #19a15f;
  --yellow: #f4a62a;
  --red: #e14b4b;
  --shadow: 0 16px 40px rgba(21, 34, 66, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(21, 34, 66, 0.1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button {
  border-color: var(--blue);
  color: #ffffff;
  background: var(--blue);
}

.primary-button:hover:not(:disabled) {
  background: var(--blue-dark);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.subtitle,
.section-heading p,
.usage-panel li {
  color: var(--muted);
}

.subtitle {
  max-width: 680px;
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.6;
}

.status-card,
.usage-panel,
.summary-card,
.heatmap-card,
.serial-card,
.table-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-card {
  display: grid;
  gap: 10px;
  min-width: 250px;
  padding: 14px;
}

.support-status,
.connection-status,
.scan-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.support-status {
  color: #24513f;
  background: #e7f7ee;
}

.connection-status.disconnected {
  color: #7a2731;
  background: #ffe9ec;
}

.connection-status.connected {
  color: #24513f;
  background: #e7f7ee;
}

.browser-warning {
  margin-bottom: 16px;
  border: 1px solid #f2b8b8;
  border-radius: 8px;
  padding: 14px 16px;
  color: #7a2731;
  background: #fff0f0;
  font-weight: 700;
}

.usage-panel {
  margin-bottom: 16px;
  padding: 18px 20px;
}

.usage-panel ol {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding-left: 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.summary-card {
  padding: 16px;
}

.summary-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.summary-card strong {
  font-size: 2rem;
  line-height: 1;
}

.summary-card.strong {
  border-top: 4px solid var(--green);
}

.summary-card.medium {
  border-top: 4px solid var(--yellow);
}

.summary-card.weak {
  border-top: 4px solid var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  margin-bottom: 16px;
}

.heatmap-card,
.serial-card,
.table-card {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.scan-status {
  color: #4d3a0b;
  background: #fff6d8;
}

.heatmap {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(25, 161, 95, 0.18) 0 17%, transparent 17.2%),
    radial-gradient(circle at center, rgba(244, 166, 42, 0.16) 0 34%, transparent 34.2%),
    radial-gradient(circle at center, rgba(225, 75, 75, 0.14) 0 50%, transparent 50.2%),
    #fbfcff;
}

.zone {
  position: absolute;
  inset: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.weak-zone {
  width: min(92%, 560px);
  aspect-ratio: 1;
  border: 2px solid rgba(225, 75, 75, 0.42);
}

.medium-zone {
  width: min(64%, 390px);
  aspect-ratio: 1;
  border: 2px solid rgba(244, 166, 42, 0.48);
}

.strong-zone {
  width: min(34%, 210px);
  aspect-ratio: 1;
  border: 2px solid rgba(25, 161, 95, 0.5);
}

.zone-label {
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.zone-label-strong {
  top: 45%;
  left: calc(50% + 92px);
  color: #14623d;
  background: #dff6e9;
}

.zone-label-medium {
  top: 29%;
  left: calc(50% + 164px);
  color: #7a4b00;
  background: #fff0c2;
}

.zone-label-weak {
  top: 12%;
  left: calc(50% + 220px);
  color: #8c2525;
  background: #ffe0e0;
}

.dongle-center {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 1px solid #c8d4ea;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(20, 87, 217, 0.18);
  transform: translate(-50%, -50%);
}

.dongle-center img {
  width: 76px;
  max-height: 76px;
  object-fit: contain;
}

.dongle-fallback {
  display: none;
  place-items: center;
  width: 74px;
  height: 44px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
}

.device-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
}

.device-bubble {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(21, 34, 66, 0.18);
  transform: translate(-50%, -50%);
}

.device-bubble.strong {
  background: var(--green);
}

.device-bubble.medium {
  background: var(--yellow);
}

.device-bubble.weak {
  background: var(--red);
}

.device-bubble::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  width: max-content;
  max-width: 260px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #ffffff;
  background: #15213a;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.device-bubble:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.serial-log {
  min-height: 548px;
  max-height: 548px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  color: #d9e6ff;
  background: #101827;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.signal-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

.signal-pill.strong {
  background: var(--green);
}

.signal-pill.medium {
  background: var(--yellow);
}

.signal-pill.weak {
  background: var(--red);
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .hero,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
  }

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

  .usage-panel ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .serial-log {
    min-height: 220px;
    max-height: 300px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .summary-grid,
  .usage-panel ol {
    grid-template-columns: 1fr;
  }

  .toolbar button {
    flex: 1 1 140px;
  }

  .heatmap {
    min-height: 470px;
  }

  .zone-label-strong {
    left: calc(50% + 58px);
  }

  .zone-label-medium {
    left: calc(50% + 90px);
  }

  .zone-label-weak {
    left: calc(50% + 108px);
  }

  .device-bubble {
    width: 50px;
    height: 50px;
    font-size: 0.66rem;
  }
}
