/* Movatic Hub — Observabilidade (ADR-0010). Paleta alinhada ao WMS. */
:root {
  --bg: #0a1420;
  --card: #101d2d;
  --card-border: #1c2f45;
  --num: #eef3fa;
  --label: #7a93b3;
  --accent: #3b82d6;
  --live: #34d399;
  --live-soft: #6ee7b7;
  --icon: #9b8fe6;
  --empty-border: #26405c;
  --empty-text: #45638a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--num);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px;
}

/* ---- Cabecalho proprio (escondido em modo-embed) ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--live);
  background: #07131f;
  border: 1px solid rgba(52, 211, 153, 0.45);
}

.brand-text strong {
  display: block;
  font-size: 17px;
}

.brand-text span {
  color: var(--label);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--label);
  font-size: 12px;
  font-weight: 600;
}

/* ---- Estados (dot) ---- */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-idle {
  background: var(--label);
}
.dot-live {
  background: var(--live);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.8);
}
.dot-down {
  background: #f87171;
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.7);
}

/* ---- Grelha de cards ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 18px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card.wide {
  grid-column: span 2;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--num);
}

.ic {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--icon);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Estado do Hub ---- */
.state-big {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
}

.kv {
  margin: 0;
  display: grid;
  gap: 8px;
}
.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--card-border);
  padding-top: 8px;
}
.kv dt {
  color: var(--label);
  font-size: 12px;
}
.kv dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.off-text {
  color: var(--empty-text);
}

/* ---- Métricas ---- */
.metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.metric strong {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--num);
}
.metric span {
  color: var(--label);
  font-size: 12px;
}
.metric-row {
  display: flex;
  gap: 28px;
}
.muted {
  margin: 0;
  color: var(--label);
  font-size: 12.5px;
  line-height: 1.5;
}
.live {
  color: var(--live-soft);
}

/* ---- Catálogo de conexões ---- */
.conn-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.conn-col h4 {
  margin: 0 0 10px;
  color: var(--label);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.conn-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.conn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: #0c1826;
}
.conn.is-off {
  border-style: dashed;
  border-color: var(--empty-border);
  background: transparent;
}
.conn.is-off .conn-name {
  color: var(--empty-text);
}
.conn.is-live {
  border-color: rgba(59, 130, 214, 0.55);
  background: rgba(59, 130, 214, 0.08);
}
.conn-name {
  font-weight: 600;
}
.conn-note {
  width: 100%;
  color: var(--label);
  font-size: 11.5px;
  font-style: normal;
}
.badge {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge-live {
  color: #0a1420;
  background: var(--accent);
}
.badge-off {
  color: var(--empty-text);
  border: 1px solid var(--empty-border);
}

/* ---- Vazios honestos ---- */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  padding: 18px;
  border: 1px dashed var(--empty-border);
  border-radius: 12px;
  color: var(--empty-text);
}
.empty strong {
  color: #6b86a8;
  font-weight: 700;
}
.empty span {
  font-size: 12px;
}

/* ---- Responsivo ---- */
@media (max-width: 940px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .card.wide {
    grid-column: auto;
  }
  .conn-cols {
    grid-template-columns: 1fr;
  }
}

/* ===========================================================================
 * Modo-embed (?embed=1): Hub embebido num iframe pelo WMS. Esconde o cabecalho
 * proprio (o menu/casca vem do WMS) e reduz o padding lateral. Ativado apenas
 * com a classe .embed no <body>; sem ela o layout e' identico ao standalone.
 * ======================================================================== */
body.embed .topbar {
  display: none;
}
body.embed .app {
  padding: 16px;
}
