:root {
  --bg: #f8fafb;
  --surface: #ffffff;
  --surface-2: #f1f5f7;
  --line: #dfe7ea;
  --ink: #1b2b31;
  --ink-soft: #5a7078;
  --ink-faint: #8b9ea5;
  --accent: #3f7d8c;
  --accent-soft: #e6f0f2;
  --ok: #4c8a6a;
  --warn: #b7873c;
  --bad: #b25f5f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 43, 49, .05), 0 6px 20px rgba(27, 43, 49, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* .login-shell and #adminView set their own display, which would otherwise
   override the hidden attribute and leave both views on screen. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* header */
.top {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.brand svg { display: block; }
.brand small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0;
  line-height: 1.3;
}
.nav { display: flex; align-items: center; gap: 8px; }

/* generic bits */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pad { padding: 22px 24px; }

h1, h2, h3 { letter-spacing: -.015em; margin: 0; }
h1 { font-size: 26px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

p { margin: 0; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #376e7b; }
.btn.ghost { border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.ok { background: #e9f3ee; color: var(--ok); }
.badge.warn { background: #f7f0e2; color: var(--warn); }
.badge.bad { background: #f6eaea; color: var(--bad); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* metric grid */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.metric { padding: 16px 18px; }
.metric .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  font-weight: 500;
}
.metric .value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; }
.metric .value span { font-size: 14px; font-weight: 400; color: var(--ink-faint); margin-left: 3px; }
.metric .sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* product demo */
.products { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.product {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: opacity .2s ease, border-color .2s ease;
}
.product { cursor: pointer; }
.product:hover { border-color: #c6d8dc; }
.product:active { transform: translateY(1px); }
.product:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.product.loading { opacity: .55; border-color: var(--accent); }
.product .thumb {
  height: 84px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.product .thumb svg { display: block; width: 100%; height: 100%; }
.product .body { padding: 12px 14px; }
.product .name { font-weight: 500; font-size: 14px; }
.product .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.product .price { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }
.product .lat { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.product .lat.slow { color: var(--warn); }
.product .lat.bad { color: var(--bad); }

/* latency strip */
.strip {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 56px;
  padding: 0 2px;
}
.strip i {
  flex: 1;
  min-width: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  opacity: .65;
  transition: height .2s ease;
}
.strip i.hi { background: var(--warn); opacity: .85; }
.strip i.max { background: var(--bad); opacity: .9; }

/* form */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 7px; }
.field-head label { font-size: 13px; font-weight: 500; }
.field-head .val { font-family: var(--mono); font-size: 13px; color: var(--accent); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(27, 43, 49, .25);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
}
input[type=password], input[type=text] {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=password]:focus, input[type=text]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63, 125, 140, .12);
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 40px; height: 22px; border-radius: 999px;
  background: #d6e0e3; position: relative; transition: background .18s ease;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(27,43,49,.25); transition: transform .18s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* layout helpers */
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
/* named .fw, not .wrap: .wrap is the page container and would add its own
   padding and max-width to any flex row using it. */
.row.fw { flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; } .mt32 { margin-top: 32px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; } .mb24 { margin-bottom: 24px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }

/* login */
.login-shell { min-height: calc(100vh - 64px); display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 380px; }
.notice {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f6eaea;
  color: var(--bad);
  border: 1px solid #ecd6d6;
}
.notice.info { background: var(--accent-soft); color: var(--accent); border-color: #d3e5e9; }

.log { font-family: var(--mono); font-size: 12px; line-height: 1.7; color: var(--ink-soft); max-height: 168px; overflow-y: auto; }
.log div { display: flex; gap: 10px; }
.log .t { color: var(--ink-faint); flex-shrink: 0; }

footer { border-top: 1px solid var(--line); margin-top: 56px; padding: 22px 0; }
.foot-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-faint); }

@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .g4, .g2, .products { grid-template-columns: 1fr; }
  .wrap { padding: 0 16px; }
  h1 { font-size: 22px; }
  .top-inner { height: auto; padding: 12px 0; flex-wrap: wrap; }
}
