:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #d9e2ec;
  --blue: #0a84d6;
  --blue-dark: #0067aa;
  --green: #12b76a;
  --red: #f04438;
  --shadow: 0 12px 36px rgba(16, 24, 40, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid rgba(217, 226, 236, 0.9);
}

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

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
}

.brand-status {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.brand-status.online {
  color: var(--green);
}

.brand-status.offline {
  color: var(--red);
}

.view {
  padding: 16px;
}

.screen-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}

.screen-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.counter {
  min-width: 38px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e6f4ff;
  color: var(--blue-dark);
  text-align: center;
  font-weight: 700;
}

.empty {
  margin-top: 42px;
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.device-list {
  display: grid;
  gap: 10px;
}

.device-button {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: inherit;
  text-align: left;
}

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

.device-name {
  font-size: 17px;
  font-weight: 700;
}

.device-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.14);
}

.back-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--blue-dark);
  font-weight: 700;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.section {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  content-visibility: auto;
  contain-intrinsic-size: auto 180px;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.kv {
  display: grid;
  gap: 9px;
}

.kv-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid #eef2f6;
}

.kv-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.kv-key {
  color: var(--muted);
}

.kv-value {
  max-width: 58%;
  text-align: right;
  font-weight: 650;
  overflow-wrap: anywhere;
}

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

.badge {
  padding: 6px 9px;
  border-radius: 8px;
  background: #eef7ff;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 700;
}

.raw-stream {
  display: grid;
  gap: 10px;
}

.raw-row {
  display: grid;
  gap: 5px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef2f6;
}

.raw-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.raw-meta {
  color: var(--muted);
  font-size: 12px;
}

.raw-data {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.raw-empty {
  margin-top: 0;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 10;
  padding: 13px 14px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(100% + 40px));
  transition: transform 180ms ease, opacity 180ms ease, visibility 180ms ease;
  visibility: hidden;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

@media (min-width: 900px) {
  .view {
    width: min(860px, 100%);
    margin: 0 auto;
  }
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .topbar {
    background: rgba(244, 247, 251, 0.94);
    backdrop-filter: blur(10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
