:root {
  --azul: #0277bd;
  --azul-escuro: #014361;
  --azul-claro: #e1f3fb;
  --ok: #2e7d32;
  --ok-bg: #e6f4ea;
  --fora: #c62828;
  --fora-bg: #fdecea;
  --neutro: #6b7785;
  --neutro-bg: #eef1f4;
  --texto: #1a2733;
  --muted: #6b7785;
  --borda: #e2e8ee;
  --fundo: #f4f8fb;
  --branco: #fff;
  --raio: 12px;
  --sombra: 0 1px 3px rgba(2, 70, 110, .08), 0 4px 16px rgba(2, 70, 110, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--texto);
  background: var(--fundo);
  line-height: 1.5;
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }

/* Topbar ------------------------------------------------------------------ */
.topbar {
  background: linear-gradient(120deg, var(--azul) 0%, var(--azul-escuro) 100%);
  color: #fff;
  box-shadow: var(--sombra);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.25rem; }
.brand-mark { font-size: 1.4rem; }
.nav { display: flex; gap: .25rem; }
.nav a {
  color: rgba(255,255,255,.85); text-decoration: none; padding: .45rem .85rem;
  border-radius: 8px; font-size: .95rem; font-weight: 500; transition: background .15s;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.ativo { background: rgba(255,255,255,.2); color: #fff; }

main.container { padding-top: 1.75rem; padding-bottom: 3rem; min-height: calc(100vh - 60px - 56px); }

/* Cabeçalhos -------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; font-size: 1.6rem; }
h1, h2 { color: var(--azul-escuro); }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .15rem; }
.breadcrumb a { color: var(--azul); text-decoration: none; }

/* Cards ------------------------------------------------------------------- */
.card {
  background: var(--branco); border: 1px solid var(--borda);
  border-radius: var(--raio); padding: 1.25rem 1.4rem; box-shadow: var(--sombra); margin-bottom: 1.25rem;
}
.card h2 { margin: 0 0 1rem; font-size: 1.1rem; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.grid-detalhe { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; align-items: start; }

.stat { text-align: center; padding: 1.3rem 1rem; }
.stat-num { font-size: 2.1rem; font-weight: 700; color: var(--azul); line-height: 1; }
.stat-label { color: var(--muted); font-size: .85rem; margin-top: .4rem; }
.stat.alerta .stat-num { color: var(--fora); }

/* Tabelas ----------------------------------------------------------------- */
.tabela { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabela th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; padding: .5rem .6rem; border-bottom: 2px solid var(--borda); }
.tabela td { padding: .65rem .6rem; border-bottom: 1px solid var(--borda); }
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr[onclick] { cursor: pointer; transition: background .12s; }
.tabela tbody tr[onclick]:hover { background: var(--azul-claro); }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela tr.inativo { opacity: .55; }
.tabela-scroll { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.contagem { display: inline-block; background: var(--neutro-bg); color: var(--muted); font-size: .8rem; padding: .05rem .5rem; border-radius: 20px; vertical-align: middle; margin-left: .3rem; }

.cod { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-weight: 600; background: var(--azul-claro); color: var(--azul-escuro); padding: .1rem .45rem; border-radius: 6px; font-size: .88em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.val-fora { color: var(--fora); font-weight: 700; }

/* Tags / status ----------------------------------------------------------- */
.tag { display: inline-block; padding: .2rem .6rem; border-radius: 20px; font-size: .8rem; font-weight: 600; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-fora { background: var(--fora-bg); color: var(--fora); }
.tag-neutro { background: var(--neutro-bg); color: var(--neutro); }
.tag-btn { border: none; cursor: pointer; font: inherit; }
.txt-ok { color: var(--ok); }
.txt-fora { color: var(--fora); }

/* Feed -------------------------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem 0; border-bottom: 1px solid var(--borda); }
.feed li:last-child { border-bottom: none; }
.feed-status { width: 10px; height: 10px; border-radius: 50%; margin-top: .45rem; flex: none; }
.feed-status.ok { background: var(--ok); }
.feed-status.fora { background: var(--fora); }
.feed a { color: var(--azul); text-decoration: none; }

/* Dados / definição ------------------------------------------------------- */
.dados { display: grid; grid-template-columns: 130px 1fr; gap: .55rem 1rem; margin: 0; }
.dados dt { color: var(--muted); font-size: .9rem; }
.dados dd { margin: 0; }
.dados a { color: var(--azul); }

/* QR ---------------------------------------------------------------------- */
.qr-card { text-align: center; }
.qr { width: 100%; max-width: 240px; height: auto; border: 1px solid var(--borda); border-radius: 8px; padding: .5rem; background: #fff; }
.qr-acoes { margin: .8rem 0; }
.url { display: block; font-size: .72rem; color: var(--muted); word-break: break-all; background: var(--fundo); padding: .4rem .5rem; border-radius: 6px; }

/* Botões ------------------------------------------------------------------ */
.btn {
  display: inline-block; background: var(--azul); color: #fff; text-decoration: none;
  border: none; padding: .6rem 1.1rem; border-radius: 8px; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: background .15s; font-family: inherit;
}
.btn:hover { background: var(--azul-escuro); }
.btn-ghost { background: transparent; color: var(--azul); border: 1px solid var(--borda); }
.btn-ghost:hover { background: var(--azul-claro); }
.btn-bloco { display: block; width: 100%; text-align: center; padding: .85rem; font-size: 1.05rem; margin-top: .5rem; }

/* Formulários ------------------------------------------------------------- */
.form-card { max-width: 640px; }
.form { display: flex; flex-direction: column; gap: 1rem; }
.campo { display: flex; flex-direction: column; gap: .3rem; }
.campo label { font-weight: 600; font-size: .9rem; }
.campo input, .campo select, .campo textarea {
  padding: .6rem .7rem; border: 1px solid var(--borda); border-radius: 8px; font-size: 1rem; font-family: inherit; background: #fff; color: var(--texto);
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(2,119,189,.15); }
.campo small { color: var(--muted); font-size: .8rem; }
.campo-linha { display: flex; gap: 1rem; }
.campo-linha .campo { flex: 1; }
.campo-uf { max-width: 90px; }
.form-acoes { margin-top: .3rem; }
.params { border: 1px solid var(--borda); border-radius: var(--raio); padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.params legend { font-weight: 700; color: var(--azul-escuro); padding: 0 .4rem; }

.erro { background: var(--fora-bg); color: var(--fora); padding: .7rem .9rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; border: 1px solid #f5c6c0; }
.erro-inline { color: var(--fora) !important; }
.vazio { color: var(--muted); }
.vazio a, .erro a { color: var(--azul); }
.inline-form { display: inline; }

/* Tela de coleta (mobile) ------------------------------------------------- */
.tela-coleta { background: var(--azul-claro); }
.coleta-wrap { max-width: 480px; margin: 0 auto; padding: 1.25rem 1.1rem 3rem; }
.coleta-head { display: flex; align-items: center; gap: .7rem; background: linear-gradient(120deg, var(--azul) 0%, var(--azul-escuro) 100%); color: #fff; padding: 1rem 1.1rem; border-radius: var(--raio); margin-bottom: 1rem; }
.coleta-head .brand-mark { font-size: 1.8rem; }
.coleta-titulo { font-weight: 700; font-size: 1.1rem; }
.coleta-sub { font-size: .9rem; opacity: .95; }
.coleta-sub .cod { background: rgba(255,255,255,.2); color: #fff; }
.coleta-local { margin: -.4rem .2rem 1rem; }
.tela-coleta .form { background: #fff; padding: 1.25rem; border-radius: var(--raio); box-shadow: var(--sombra); }

/* Confirmação ------------------------------------------------------------- */
.confirma { background: #fff; border-radius: var(--raio); padding: 1.6rem; text-align: center; box-shadow: var(--sombra); border-top: 5px solid var(--ok); }
.confirma.conf-fora { border-top-color: var(--fora); }
.confirma h1 { margin: .3rem 0; font-size: 1.4rem; }
.confirma-icone { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 1.8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto .5rem; }
.conf-fora .confirma-icone { background: var(--fora-bg); color: var(--fora); }
.resumo { background: #fff; border-radius: var(--raio); padding: .5rem 1.1rem; margin: 1rem 0; box-shadow: var(--sombra); }
.resumo-linha { display: flex; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--borda); }
.resumo-linha:last-child { border-bottom: none; }

/* Rodapé ------------------------------------------------------------------ */
.rodape { border-top: 1px solid var(--borda); background: #fff; color: var(--muted); font-size: .85rem; padding: 1.1rem 0; text-align: center; }

/* Responsivo -------------------------------------------------------------- */
@media (max-width: 820px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-detalhe { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
}
@media (max-width: 480px) {
  .nav a { padding: .4rem .55rem; font-size: .85rem; }
  .brand-name { display: none; }
}
