/* ---------------------------------------------------------------------------
   Bespoke Sensor Applications

   One hand-written stylesheet, no framework. The previous site pulled in
   Bootstrap 5 beta, jQuery, jQuery Easing, Isotope, Owl Carousel, VenoBox and
   an icon font to render what is essentially a few forms, a table and a chart.
   All of that was unmaintained third-party code shipped to every visitor.

   Layout uses CSS grid and flexbox; colours are declared once as custom
   properties; dark mode follows the visitor's system preference.
--------------------------------------------------------------------------- */

:root {
  --bg:          #f6f7f9;
  --surface:     #ffffff;
  --surface-alt: #f0f2f5;
  --border:      #d8dce3;
  --text:        #1c2530;
  --text-muted:  #5c6873;
  --accent:      #1f6feb;
  --accent-dark: #1a5ac4;
  --ok:          #1a7f56;
  --warn:        #a86300;
  --danger:      #c2352b;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --header-bg:   #16202b;
  --header-text: #f2f5f8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #12171d;
    --surface:     #1a212a;
    --surface-alt: #222b36;
    --border:      #313d4a;
    --text:        #e6edf3;
    --text-muted:  #99a5b2;
    --accent:      #559bff;
    --accent-dark: #7bb2ff;
    --ok:          #4ac08a;
    --warn:        #d99a2b;
    --danger:      #ef6b60;
    --shadow:      0 1px 3px rgba(0, 0, 0, .4);
    --header-bg:   #0d1319;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1120px, calc(100% - 2.5rem)); margin-inline: auto; }

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.9rem; letter-spacing: -.015em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

/* --- header ------------------------------------------------------------- */

.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 68px;
  flex-wrap: wrap;
}

.brand {
  color: var(--header-text);
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.2;
  text-decoration: none;
}
.brand span { font-weight: 400; opacity: .8; }

.site-nav { display: flex; align-items: center; gap: 1.4rem; }
.site-nav a {
  color: var(--header-text);
  text-decoration: none;
  font-size: .95rem;
  opacity: .85;
  padding: .25rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover  { opacity: 1; }
.site-nav a.active { opacity: 1; border-bottom-color: var(--accent); }

.site-nav .btn-link {
  background: var(--accent);
  border-radius: 6px;
  padding: .45rem .95rem;
  opacity: 1;
  border-bottom: 0;
}
.site-nav .btn-link:hover { background: var(--accent-dark); }

/* --- main / footer ------------------------------------------------------ */

main.wrap { padding: 2.25rem 0 4rem; min-height: 60vh; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: .88rem;
}

/* --- cards -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-narrow { max-width: 460px; margin-inline: auto; }

.grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}

/* --- sensor tiles ------------------------------------------------------- */

.sensor-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s, transform .12s;
}
.sensor-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  color: inherit;
}
.sensor-tile h3 { margin-bottom: .3rem; }
.sensor-tile .meta { color: var(--text-muted); font-size: .87rem; }

/* --- readings ----------------------------------------------------------- */

.reading-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.reading {
  flex: 1 1 150px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.reading .label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.reading .value { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.reading .unit  { font-size: .9rem; color: var(--text-muted); margin-left: .15rem; }

/* --- parameter selector ------------------------------------------------- */

.param-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.1rem; }
.param-tabs a {
  padding: .4rem .9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
}
.param-tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#chart { width: 100%; height: 460px; }

/* --- forms -------------------------------------------------------------- */

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=file], select, textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field { margin-bottom: 1.1rem; }
.field .hint { font-size: .82rem; color: var(--text-muted); margin-top: .3rem; font-weight: 400; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: .62rem 1.25rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }

/* --- flash / alerts ----------------------------------------------------- */

.flash {
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  margin-bottom: 1.5rem;
  border: 1px solid;
}
.flash-info    { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: var(--accent); }
.flash-success { background: color-mix(in srgb, var(--ok) 12%, transparent);     border-color: var(--ok); }
.flash-error   { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); }

/* --- tables ------------------------------------------------------------- */

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

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: .6rem .7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
table.data tbody tr:hover { background: var(--surface-alt); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- status pills ------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.pill-ok    { background: color-mix(in srgb, var(--ok) 18%, transparent);     color: var(--ok); }
.pill-warn  { background: color-mix(in srgb, var(--warn) 20%, transparent);   color: var(--warn); }
.pill-error { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.pill-muted { background: var(--surface-alt); color: var(--text-muted); }

/* --- one-time secret reveal --------------------------------------------- */

.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: .9rem 1rem;
  word-break: break-all;
  font-size: .9rem;
  user-select: all;
}

.muted { color: var(--text-muted); }
.small { font-size: .87rem; }
.stack > * + * { margin-top: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* --- marketing home ----------------------------------------------------- */

.hero { padding: 3.5rem 0 2.5rem; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
.hero p  { font-size: 1.1rem; color: var(--text-muted); max-width: 62ch; margin-inline: auto; }
.hero .btn { margin-top: 1.6rem; }

.feature h3 { margin-bottom: .35rem; }
.feature p  { color: var(--text-muted); margin: 0; }
