:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #0c1815;
  --panel-2: #10201c;
  --line: #1d332d;
  --text: #e8f4ef;
  --muted: #8ca69c;
  --green: #41e6a0;
  --green-soft: rgba(65, 230, 160, .12);
  --amber: #f7bb62;
  --amber-soft: rgba(247, 187, 98, .11);
  --red: #ff7878;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(65, 230, 160, .12), transparent 32rem),
    linear-gradient(180deg, #08120f, var(--bg));
}

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 28px; }
.topbar, .panel-heading, footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 610; letter-spacing: -.055em; }
h2 { font-size: 1.35rem; letter-spacing: -.025em; }
.eyebrow { color: var(--green); font-size: .68rem; font-weight: 750; letter-spacing: .17em; margin-bottom: 8px; }

.connection {
  display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .85rem;
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 13px; background: rgba(12, 24, 21, .78);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.connection.online .dot { background: var(--green); box-shadow: 0 0 12px var(--green); }
.connection.offline .dot { background: var(--red); box-shadow: 0 0 12px var(--red); }

.notice {
  display: flex; gap: 15px; margin: 30px 0 18px; padding: 17px 19px; border: 1px solid rgba(247,187,98,.3);
  border-radius: 14px; background: var(--amber-soft); color: #f8dfba;
}
.notice.ok { border-color: rgba(65,230,160,.3); background: var(--green-soft); color: #c4f6df; }
.notice.error { border-color: rgba(255,120,120,.35); background: rgba(255,120,120,.1); color: #ffc2c2; }
.notice-icon { display: grid; place-items: center; flex: 0 0 26px; height: 26px; border: 1px solid currentColor; border-radius: 50%; font-weight: 800; }
.notice p { color: var(--muted); margin-top: 4px; line-height: 1.45; font-size: .88rem; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric { min-height: 145px; border: 1px solid var(--line); border-radius: 15px; padding: 20px; background: linear-gradient(145deg, var(--panel-2), var(--panel)); }
.metric.primary { background: linear-gradient(145deg, rgba(65,230,160,.17), var(--panel)); }
.metric-label { display: block; color: var(--muted); font-size: .76rem; margin-bottom: 23px; }
.metric strong { display: block; font-size: 2rem; font-weight: 580; letter-spacing: -.04em; line-height: 1; }
.metric strong.device-id { font-size: 1.05rem; letter-spacing: .02em; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; padding-top: 8px; }
.metric small { display: block; color: var(--muted); font-size: .72rem; margin-top: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel { margin-top: 12px; border: 1px solid var(--line); border-radius: 15px; background: rgba(12,24,21,.9); overflow: hidden; }
.panel-heading { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.refresh { color: var(--muted); font-size: .72rem; }
.interval-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; gap: 14px; align-items: end; padding: 20px 22px; }
.interval-form label { display: grid; gap: 8px; color: var(--muted); font-size: .72rem; }
.interval-form select, .interval-form input { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 9px; padding: 0 12px; color: var(--text); background: #091411; font: inherit; font-size: .85rem; outline: none; }
.interval-form select:focus, .interval-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(65,230,160,.1); }
.interval-form button { height: 42px; border: 0; border-radius: 9px; padding: 0 17px; color: #052116; background: var(--green); font-weight: 750; cursor: pointer; }
.interval-form button:disabled { opacity: .55; cursor: wait; }
.control-help { grid-column: 1 / -1; color: var(--muted); font-size: .74rem; }
.control-help.success { color: var(--green); }
.control-help.error-text { color: var(--red); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { color: #6f8d82; font-size: .66rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 650; text-align: left; padding: 13px 16px; background: rgba(6, 15, 12, .45); }
td { padding: 15px 16px; border-top: 1px solid rgba(29,51,45,.65); color: #c6d9d2; vertical-align: top; }
tbody tr:hover { background: rgba(65,230,160,.025); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .73rem; }
.muted { color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: 5px 8px; color: var(--amber); background: var(--amber-soft); white-space: nowrap; }
.badge.good { color: var(--green); background: var(--green-soft); }
.badge.bad { color: var(--red); background: rgba(255,120,120,.1); }
.payload { min-width: 280px; max-width: 390px; color: #b9cec6; }
.human-data { display: flex; flex-wrap: wrap; gap: 5px 12px; line-height: 1.45; }
.human-data span { white-space: nowrap; }
.human-data b { color: var(--green); font-weight: 600; }
details { margin-top: 8px; color: #607a70; }
summary { cursor: pointer; user-select: none; font-size: .68rem; }
.raw-frame { display: block; margin-top: 6px; word-break: break-all; font-size: .64rem; line-height: 1.4; }
.sensor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); }
.sensor-card { min-height: 112px; padding: 17px 19px; background: var(--panel); }
.sensor-card .label { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 15px; }
.sensor-card strong { display: block; font-size: 1.35rem; font-weight: 580; letter-spacing: -.025em; overflow-wrap: anywhere; }
.sensor-card small { display: block; color: #5f786f; font-size: .64rem; margin-top: 10px; }
.empty { text-align: center; color: var(--muted); padding: 45px; }

footer { color: #5f786f; font-size: .68rem; padding: 17px 2px 0; }

@media (max-width: 850px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .sensor-grid { grid-template-columns: repeat(2, 1fr); }
  .shell { width: min(100% - 24px, 1180px); padding-top: 22px; }
  .interval-form { grid-template-columns: 1fr 1fr; }
  .interval-form button { grid-column: 1 / -1; }
}

@media (max-width: 540px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .sensor-grid { grid-template-columns: 1fr; }
  .metric { min-height: 125px; }
  .interval-form { grid-template-columns: 1fr; }
  .interval-form button { grid-column: auto; }
  footer { align-items: flex-start; flex-direction: column; }
}
