/* Mini THP web — SciGlob Instruments.
 *
 * Brand:  SciGlob blue #105EAA, sky #88D3F5 (sampled from the logo artwork).
 * Type:   Inter (variable, self-hosted), tabular figures for every reading.
 *
 * Data colours are the data-viz reference slots 1-3, validated with the six
 * checks on each surface, all pairs:
 *   light on #ffffff  CVD dE 12.6, normal 23.0; orange and aqua sit under 3:1
 *                     on white, relieved by the title + large value in every
 *                     tile and the table view
 *   dark  on #101722  CVD dE 12.8, normal 19.4, every slot >= 3:1
 * Brand colours dress the chrome; they never stand in for a data series.
 */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --brand: #105eaa;
  --brand-sky: #88d3f5;
  --brand-ink: #0b4a87;          /* brand blue for text on light: 8.6:1 */

  --plane: #f4f7fb;
  --surface: #ffffff;
  --sunken: #f3f6fa;
  --ink: #0e1a2b;
  --ink-2: #3d4b60;
  --ink-3: #66738a;              /* 4.7:1 on white */
  --grid: #e9eef4;
  --rule: #c7d1de;
  --line: rgba(14, 26, 43, .08);
  --line-2: rgba(14, 26, 43, .14);
  --glow-1: rgba(136, 211, 245, .32);
  --glow-2: rgba(16, 94, 170, .10);
  --dotgrid: rgba(16, 94, 170, .10);

  --s1: #257de0;                 /* temperature */
  --s2: #f47230;                 /* pressure    */
  --s3: #00b894;                 /* humidity    */
  --good: #0aac23; --warn: #f2a600; --crit: #dc3c3d;

  --shadow-1: 0 1px 2px rgba(14, 26, 43, .05), 0 6px 20px -10px rgba(14, 26, 43, .14);
  --shadow-2: 0 2px 6px rgba(14, 26, 43, .06), 0 22px 48px -20px rgba(16, 94, 170, .28);
  --tile-top: rgba(255, 255, 255, 1);
  --r-lg: 20px;
  --r: 16px;
  --r-sm: 11px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand-ink: #88d3f5;
    --plane: #080d14;
    --surface: #101722;
    --sunken: #0c121b;
    --ink: #eef3f9;
    --ink-2: #b6c2d3;
    --ink-3: #8593a8;
    --grid: #1c2533;
    --rule: #3a4658;
    --line: rgba(255, 255, 255, .07);
    --line-2: rgba(255, 255, 255, .13);
    --glow-1: rgba(16, 94, 170, .26);
    --glow-2: rgba(136, 211, 245, .07);
    --dotgrid: rgba(136, 211, 245, .07);
    --s1: #338ced;
    --s2: #e76624;
    --s3: #00a888;
    --good: #0aac23; --warn: #fbb315; --crit: #dc3c3d;
    --shadow-1: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -16px rgba(0, 0, 0, .7);
    --shadow-2: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 30px 60px -24px rgba(0, 0, 0, .8);
    --tile-top: rgba(255, 255, 255, .025);
  }
}

/* ── base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--plane); color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column;
}
/* atmosphere: a soft brand-coloured glow and a faint instrument dot-grid,
   both fading out below the header */
body::before, body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
}
body::before {
  background:
    radial-gradient(70rem 34rem at -8% -16%, var(--glow-1), transparent 62%),
    radial-gradient(56rem 30rem at 108% -12%, var(--glow-2), transparent 60%);
}
body::after {
  background-image: radial-gradient(var(--dotgrid) 1px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, transparent 460px);
          mask-image: linear-gradient(to bottom, #000 0, transparent 460px);
}
[hidden] { display: none !important; }
img { display: block; max-width: 100%; height: auto; }

.wrap {
  width: 100%; max-width: 1200px; margin: 0 auto; flex: 1;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           24px max(20px, env(safe-area-inset-left));
}
@media (max-width: 560px) { .wrap { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); } }

/* ── header ───────────────────────────────────────────────────────────── */
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 0 26px; }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; color: inherit; text-decoration: none; }
.brand .logo { height: 38px; width: auto; }
.brand .divider { width: 1px; height: 30px; background: var(--line-2); flex: 0 0 auto; }
.brand .product { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand .product b { font-size: 16px; font-weight: 650; letter-spacing: -.015em; white-space: nowrap; }
.brand .product small { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.spacer { flex: 1; }
@media (max-width: 560px) {
  .bar { gap: 10px; padding-bottom: 18px; }
  .brand { gap: 11px; }
  .brand .logo { height: 30px; }
  .brand .divider { height: 24px; }
  .brand .product small { display: none; }
}

.pill {
  display: inline-flex; align-items: center; gap: 9px; height: 36px; padding: 0 14px 0 12px;
  border-radius: 999px; background: color-mix(in srgb, var(--surface) 78%, transparent);
  border: 1px solid var(--line); box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: 13px; font-weight: 550; color: var(--ink-2); white-space: nowrap; min-width: 0;
}
.pill span:last-child { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .pill { height: 34px; padding: 0 12px 0 10px; font-size: 12.5px; } }

/* status dots: a live dot breathes; everything else holds still */
.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: 0 0 auto; }
.dot.ok { background: var(--good); }
.dot.ok::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--good); opacity: 0; animation: ping 2.4s cubic-bezier(.2,.6,.3,1) infinite;
}
.dot.warn { background: var(--warn); }
.dot.err { background: var(--crit); }
.dot.busy { background: var(--brand-sky); animation: breathe 1.2s ease-in-out infinite; }
@keyframes ping { 0% { transform: scale(.6); opacity: .55; } 80%, 100% { transform: scale(1.5); opacity: 0; } }
@keyframes breathe { 50% { opacity: .3; } }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm); cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2);
  box-shadow: 0 1px 2px rgba(14, 26, 43, .05);
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.005em; text-decoration: none;
  transition: border-color .15s, background .15s, transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { border-color: var(--rule); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, canvas:focus-visible, .brand:focus-visible {
  outline: 2px solid var(--brand-sky); outline-offset: 3px;
}
.btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.btn.primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(180deg, #1a6fc2, var(--brand));
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 8px 22px -10px rgba(16, 94, 170, .75);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { height: 50px; padding: 0 28px; font-size: 15.5px; border-radius: 14px; }
.btn.icon { width: 40px; padding: 0; }
@media (max-width: 560px) { #phoneBtn .lbl { display: none; } #phoneBtn { width: 36px; height: 36px; padding: 0; } }

/* ── hero (waiting, connect, can't-connect) ───────────────────────────── */
.hero {
  position: relative; overflow: hidden; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); padding: 56px 24px 44px; margin-bottom: 22px;
}
.hero::before {          /* soft brand light behind the mark */
  content: ""; position: absolute; left: 50%; top: -120px; width: 620px; height: 420px;
  transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(closest-side, var(--glow-1), transparent);
}
.hero > * { position: relative; }
.hero .mark { position: relative; width: 104px; height: 104px; margin: 0 auto 26px; display: grid; place-items: center; }
.hero .mark img { width: 72px; height: auto; }
.hero .mark .ring {
  position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--brand-sky);
  opacity: 0; animation: radar 3.6s cubic-bezier(.15,.55,.35,1) infinite;
}
.hero .mark .ring:nth-child(2) { animation-delay: 1.2s; }
.hero .mark .ring:nth-child(3) { animation-delay: 2.4s; }
.hero.still .mark .ring { display: none; }
@keyframes radar { 0% { transform: scale(.55); opacity: .7; } 100% { transform: scale(1.9); opacity: 0; } }

.hero .eyebrow {
  display: inline-block; margin-bottom: 12px; font-size: 12px; font-weight: 650; letter-spacing: .14em;
  text-transform: uppercase; color: var(--brand-ink);
}
.hero h2 { margin: 0 0 10px; font-size: clamp(24px, 4.4vw, 32px); font-weight: 700; letter-spacing: -.028em; line-height: 1.15; }
.hero p { margin: 0 auto 10px; max-width: 540px; color: var(--ink-2); font-size: 15.5px; }
.hero .actions { margin: 26px 0 8px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero .fine { font-size: 13px; color: var(--ink-3); max-width: 460px; }
.hero ol {
  text-align: left; max-width: 480px; margin: 22px auto 4px; padding: 0; list-style: none;
  counter-reset: step; display: grid; gap: 10px;
}
.hero ol li {
  counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px;
  color: var(--ink-2); font-size: 14.5px;
}
.hero ol li::before {
  content: counter(step); width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 700; font-size: 13.5px; color: #fff; background: var(--brand);
}
.hero code {
  font-family: var(--mono); font-size: 13px; background: var(--surface);
  padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line-2); white-space: nowrap;
}
.features + .fine { margin-top: 20px; }
.features { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 30px 0 0; padding: 0; list-style: none; }
.features li {
  display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px 7px 8px; border-radius: 999px;
  background: var(--sunken); border: 1px solid var(--line); font-size: 13.5px; font-weight: 550; color: var(--ink-2);
}
@media (max-width: 560px) { .hero { padding: 44px 18px 34px; } }

/* measure identity: icon chip in the series colour (never the text) */
[data-k="T"] { --c: var(--s1); }
[data-k="P"] { --c: var(--s2); }
[data-k="H"] { --c: var(--s3); }
.ico {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.ico svg { width: 17px; height: 17px; }
.features .ico { width: 24px; height: 24px; border-radius: 999px; }
.features .ico svg { width: 14px; height: 14px; }

/* ── a sensor ─────────────────────────────────────────────────────────── */
.sensor { margin-bottom: 30px; animation: rise .45s cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.sensor-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 0 4px 12px; }
.sensor-head .title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.sensor-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.chip {
  align-self: center; font-size: 12px; font-weight: 600; color: var(--brand-ink); padding: 2px 9px;
  border-radius: 999px; background: color-mix(in srgb, var(--brand-sky) 22%, transparent);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.serial { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.sstate { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 550; color: var(--ink-2); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .tiles { grid-template-columns: 1fr; gap: 12px; } }

.tile {
  position: relative; min-width: 0; overflow: hidden;
  background: linear-gradient(180deg, var(--tile-top), transparent 60%), var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: 18px 20px 14px;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.tile::before {          /* a hairline of the series colour across the top */
  content: ""; position: absolute; left: 20px; right: 20px; top: 0; height: 2px; border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, transparent, var(--c), transparent); opacity: .55;
}
@media (hover: hover) { .tile:hover { border-color: var(--line-2); box-shadow: var(--shadow-2); } }

.tile-head { display: flex; flex-direction: column; gap: 12px; }
.label { display: flex; align-items: center; gap: 10px; }
.label .name { font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.val { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.val b {
  font-size: 50px; font-weight: 650; line-height: 1; letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  color: var(--ink); transition: color .3s;
}
.val i { font-style: normal; font-size: 17px; color: var(--ink-3); font-weight: 550; letter-spacing: -.01em; }
.sensor.dim .val b { color: var(--ink-3); }

@media (max-width: 860px) {
  /* phone: name left, value right, chart beneath */
  .tile { padding: 14px 16px 12px; border-radius: var(--r); }
  .tile-head { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
  .val b { font-size: 38px; }
  .val i { font-size: 15px; }
}

.plot { position: relative; margin: 14px -4px 0; }
.plot canvas { display: block; width: 100%; height: 96px; touch-action: pan-y; cursor: crosshair; }
@media (max-width: 860px) { .plot { margin-top: 10px; } .plot canvas { height: 72px; } }

.tip {
  position: absolute; top: -10px; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 6px 10px;
  font-size: 13px; white-space: nowrap; z-index: 3; box-shadow: var(--shadow-2);
  font-variant-numeric: tabular-nums;
}
.tip b { font-weight: 700; }
.tip em { display: block; font-style: normal; color: var(--ink-3); font-size: 11.5px; }

.foot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px;
  color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.foot b { color: var(--ink-2); font-weight: 600; }
.trend { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.trend svg { width: 12px; height: 12px; }

/* ── tools & table ────────────────────────────────────────────────────── */
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.tablewrap {
  max-height: 380px; overflow: auto; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow-1); margin-bottom: 22px;
}
table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 16px; text-align: right; white-space: nowrap; }
th {
  position: sticky; top: 0; background: var(--surface); color: var(--ink-3); font-size: 11.5px;
  font-weight: 650; letter-spacing: .07em; text-transform: uppercase; border-bottom: 1px solid var(--line-2);
}
th:nth-child(-n+2), td:nth-child(-n+2) { text-align: left; }
td:first-child { color: var(--ink-3); }
td:nth-child(2) { color: var(--ink-2); font-weight: 550; }
tbody tr:nth-child(even) { background: var(--sunken); }

/* ── footer ───────────────────────────────────────────────────────────── */
.site-foot {
  width: 100%; max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 18px max(20px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px;
}
.site-foot img { width: 18px; height: auto; }
.site-foot b { color: var(--ink-2); font-weight: 600; }
.site-foot .sep { opacity: .5; }

/* ── phone dialog ─────────────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line-2); border-radius: 24px; padding: 0; width: min(440px, calc(100vw - 28px));
  background: var(--surface); color: var(--ink); box-shadow: 0 40px 100px -20px rgba(0, 0, 0, .55);
}
dialog[open] { animation: pop .22s cubic-bezier(.2,.8,.3,1); }
dialog::backdrop { background: rgba(5, 12, 22, .5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dlg { padding: 28px 26px 22px; text-align: center; }
.dlg .dlg-mark { width: 40px; margin: 0 auto 12px; }
.dlg h2 { margin: 0 0 4px; font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.dlg p { margin: 0 0 18px; color: var(--ink-2); font-size: 14.5px; }
.qr {
  width: 228px; height: 228px; margin: 0 auto 14px; padding: 12px; border-radius: 18px; background: #fff;
  box-shadow: 0 0 0 1px rgba(14, 26, 43, .08), 0 18px 40px -18px rgba(16, 94, 170, .45);
}
.qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.url {
  font-family: var(--mono); font-size: 15px; font-weight: 600; word-break: break-all; color: var(--brand-ink);
  background: var(--sunken); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  margin-bottom: 8px; -webkit-user-select: all; user-select: all;
}
.others { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; }
.dlg ul { font-size: 13px; color: var(--ink-2); text-align: left; margin: 14px 0 20px; padding-left: 18px; }
.dlg ul li { margin: 5px 0; }
.dlg .row { display: flex; gap: 10px; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
