:root {
  --bg: #07080c;
  --bg-2: #10131a;
  --panel: rgba(16, 19, 26, 0.92);
  --text: #f4f7fb;
  --muted: #8b95a7;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #3dff6a;
  --accent-dim: rgba(61, 255, 106, 0.16);
  --want: #38bdf8;
  --needle: #f8fafc;
  --warn: #fbbf24;
  --bad: #f87171;
  --ok: #3dff6a;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

html.sun {
  --bg: #f4e27a;
  --bg-2: #ffe566;
  --panel: #111111;
  --text: #111111;
  --muted: #3f3f3f;
  --line: rgba(0, 0, 0, 0.2);
  --accent: #007a1f;
  --accent-dim: #d7ffd9;
  --want: #0047ab;
  --needle: #111;
  --ok: #007a1f;
  --bad: #9f0000;
  --warn: #8a5a00;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(56, 189, 248, 0.12), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(61, 255, 106, 0.08), transparent 45%),
    var(--bg);
  color: var(--text);
  padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
}

html.sun body { background: var(--bg); }

.app { max-width: 760px; margin: 0 auto; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 42px; height: 42px; flex: none;
  filter: drop-shadow(0 0 10px rgba(61, 255, 106, 0.35));
}
.brand h1 {
  margin: 0; font-size: 1.15rem; letter-spacing: 0.02em;
}
.brand p {
  margin: 0; color: var(--muted); font-size: 0.78rem;
}
.top-actions { display: flex; gap: 8px; }

.icon-btn, .btn {
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.05rem;
}
.btn {
  padding: 12px 16px;
  font-size: 0.95rem;
}
.btn.primary {
  background: var(--accent);
  color: #04140a;
  border-color: transparent;
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.full { width: 100%; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
html.sun .card { color: #f4f7fb; --text: #f4f7fb; --muted: #b7c0ce; --needle: #f8fafc; }

.conn {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.field label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: #0b0d12;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 1rem;
}
.status-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; color: var(--muted); font-size: 0.86rem;
}
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: #667;
  box-shadow: 0 0 0 4px rgba(102, 102, 119, 0.15);
}
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px var(--accent-dim); }
.dot.demo { background: var(--want); }
.dot.bad { background: var(--bad); }

.banner {
  display: none;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  border: 1px solid var(--line);
}
.banner.show { display: block; }
.banner.web {
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
}
.banner.error {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
}

.verdict {
  text-align: center;
  padding: 18px 12px 8px;
}
.verdict .kicker {
  color: var(--muted);
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  text-transform: uppercase;
}
.verdict h2 {
  margin: 6px 0 4px;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  letter-spacing: 0.04em;
}
.verdict.ok h2 { color: var(--ok); }
.verdict.warn h2 { color: var(--warn); }
.verdict.bad h2 { color: var(--bad); }
.verdict.idle h2 { color: var(--muted); }

.nudge {
  display: grid;
  gap: 8px;
  margin: 8px 0 4px;
}
.nudge-item {
  background: #0b0d12;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: clamp(1.15rem, 4.4vw, 1.55rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
}
.nudge-item small {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.gauges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 560px) {
  .gauges { grid-template-columns: 1fr; }
}
.gauge-card h3 {
  margin: 0 0 4px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nums {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.nums strong { font-size: 1.45rem; }
.nums span { color: var(--muted); font-size: 0.8rem; }
.gauge-svg { width: 100%; height: auto; color: var(--text); }
.compass-label { fill: currentColor; font-size: 11px; opacity: 0.7; }

.alerts { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.chip.ok {
  background: var(--accent-dim);
  color: var(--ok);
  border-color: transparent;
}

.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  font-size: 0.86rem;
}
.meta dt { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.meta dd { margin: 2px 0 8px; word-break: break-all; }

.help-list { margin: 0; padding-left: 18px; color: var(--muted); }
.help-list li { margin: 8px 0; }
.danger { color: #fecaca; font-weight: 700; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
  padding: 12px;
}
.overlay.show { display: flex; }
.sheet {
  width: min(640px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}
.sheet h2 { margin-top: 0; }
.legal {
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.45;
  margin-top: 8px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(900px 420px at 20% 0%, rgba(56, 189, 248, 0.16), transparent 50%),
    radial-gradient(700px 360px at 90% 20%, rgba(61, 255, 106, 0.1), transparent 45%),
    #07080c;
}
.login-screen.hidden { display: none; }
.login-box { width: min(400px, 100%); }
.login-box h1 { margin: 8px 0 4px; }
.user-chip {
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-list { display: grid; gap: 8px; }
.report-item {
  background: #0b0d12;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
}
.report-item b { display: block; margin-bottom: 2px; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.app-main.hidden { display: none; }
.field + .field { margin-top: 10px; }
select.report-input, textarea.report-input {
  width: 100%;
  background: #0b0d12;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 1rem;
  font-family: inherit;
}
textarea.report-input { min-height: 72px; resize: vertical; }
.login-error { color: #fecaca; min-height: 1.2em; font-size: 0.9rem; }

.user-actions { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.user-actions .btn { padding:8px 10px; font-size:0.78rem; min-width:0; flex:1; }

.debug {
  display: none;
  margin-top: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: pre-wrap;
}
.debug.show { display: block; }
