:root {
  --bg: #0b1220;
  --surface: #131d31;
  --surface-2: #1b273f;
  --line: #27344e;
  --text: #e8edf7;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* o atributo hidden precisa vencer o display das classes (.gate, .app, ...) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: 0.2px; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
}
.dot.live { background: var(--ok); animation: pulse 1.8s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.badge {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

main { padding: 16px; display: grid; gap: 14px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.warn {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
}

.status-card .status-line { margin-bottom: 4px; }

.status-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 4px 0;
}
.label { color: var(--muted); font-size: 13px; }
.value { font-size: 15px; font-weight: 600; }
.value.ok { color: var(--ok); }
.value.warn { color: var(--warn); }
.value.off { color: var(--muted); }

.hint { color: var(--muted); font-size: 13px; margin: 8px 0 12px; line-height: 1.45; }

.actions { display: flex; gap: 10px; }
.actions.wrap { flex-wrap: wrap; }

button {
  flex: 1 1 auto;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06263a; }
button.danger { background: rgba(248, 113, 113, 0.15); border-color: rgba(248, 113, 113, 0.45); color: #fecaca; }
button.ghost { background: transparent; color: var(--muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.metric { display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big.alert { color: var(--warn); }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h2 { font-size: 14px; margin: 0; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }
.count { font-size: 12px; color: var(--muted); }

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  font-size: 13px;
  -webkit-overflow-scrolling: touch;
}
.log li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid rgba(39, 52, 78, 0.6);
}
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.log .msg { flex: 1 1 auto; }
.log li.ev-ok .msg { color: var(--ok); }
.log li.ev-warn .msg { color: var(--warn); }
.log li.ev-err .msg { color: var(--danger); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.foot { color: var(--muted); text-align: center; padding: 4px 0 24px; word-break: break-word; }

/* --------------------------------------------------------- identificacao */

.field { display: grid; gap: 6px; margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field span { color: var(--muted); font-size: 13px; }
.field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* 16px evita o zoom automatico do iOS ao focar */
}
.field input:disabled { opacity: 0.55; }

.field-hint { color: var(--muted); font-size: 12px; }

/* cartao que explica o que aconteceu enquanto o app esteve fora de foco */
.away {
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 6px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
  font-size: 14px;
  line-height: 1.45;
}
.away.ok {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.45);
  color: #a7f3d0;
}
.away strong { font-size: 15px; }

.field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
}
.field select:disabled { opacity: 0.55; }
