/* Escala global ~95%: 1rem = 15.2px (meio termo entre o default 16px e os 14.4px da v1).
   Pico.css usa rem em todos os tamanhos, então tudo escala junto. */
html { font-size: 95%; }

:root {
  --topbar-bg: #1b2530;
  --topbar-border: #2a3744;
  --accent: #00d4aa;
}

body { min-height: 100vh; display: flex; flex-direction: column; }
main.container { flex: 1; padding-top: 2rem; padding-bottom: 3rem; }
footer.container { padding: 1rem 0; opacity: .5; text-align: center; }

/* Topbar */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  padding: .75rem 0;
}
.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--pico-color);
  text-decoration: none;
}
.topbar nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.topbar nav a {
  color: var(--pico-muted-color);
  text-decoration: none;
  font-size: .95rem;
}
.topbar nav a:hover { color: var(--pico-color); }
.topbar nav a.active { color: var(--accent); font-weight: 600; }
.topbar nav a.logout { color: #ff7b7b; }

/* Login card */
.login-card {
  max-width: 380px;
  margin: 4rem auto;
}
.login-card .error {
  color: #ff7b7b;
  font-size: .9rem;
  margin: .5rem 0;
}

/* Cards de stats */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.cards .stat {
  margin: 0;
  padding: 1rem 1.25rem;
  text-align: left;
}
.cards .stat small {
  display: block;
  color: var(--pico-muted-color);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .25rem;
}
.cards .stat strong {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

/* Tabelas compactas */
table { font-size: .92rem; }
table th { font-weight: 600; }

/* Status badges */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-on  { background: rgba(0,212,170,.15); color: var(--accent); }
.badge-off { background: rgba(255,123,123,.15); color: #ff7b7b; }
.badge-warn{ background: rgba(255,200,0,.15);  color: #ffc800; }

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.page-header h1 { margin: 0; }
.back-link { color: var(--pico-muted-color); text-decoration: none; }
.back-link:hover { color: var(--accent); }

/* Inline forms */
.inline-form {
  display: flex;
  gap: .5rem;
  margin: 0;
}
.inline-form input { flex: 1; margin: 0; }
.inline-form button { margin: 0; flex-shrink: 0; }

/* Mini buttons (compact) */
[role="button"].mini, .button.mini {
  padding: .25rem .6rem;
  font-size: .85rem;
}

/* Token display */
code.token {
  display: inline-block;
  padding: .5rem .75rem;
  background: rgba(0,212,170,.1);
  border: 1px dashed rgba(0,212,170,.3);
  border-radius: .25rem;
  font-size: .85rem;
  word-break: break-all;
  transition: background .2s;
}
code.token:hover { background: rgba(0,212,170,.2); }

/* Grid de checkboxes para flags */
.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: .5rem 1rem;
}
.flag-grid label { margin: 0; font-size: .92rem; }

/* Linha de agendamento */
.schedule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
  margin: 0;
}
.schedule-row:last-child { border-bottom: none; }
.schedule-row .kind-label { min-width: 100px; font-weight: 600; }
.schedule-row .schedule-prefix { opacity: .7; font-size: .9rem; }
.schedule-row .schedule-time {
  margin: 0; width: 110px; flex: 0 0 auto;
  font-family: monospace; font-size: 1rem;
}
.schedule-row .schedule-day {
  margin: 0; width: 60px; flex: 0 0 auto;
  text-align: center;
}
.schedule-row label { margin: 0; white-space: nowrap; }
.schedule-row button { margin: 0; }

textarea { font-family: monospace; font-size: .9rem; }

/* Filtros */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: 0;
}
.filter-form select { margin: 0; }
.filter-form label { margin: 0; white-space: nowrap; }
.filter-form button, .filter-form a[role="button"] { margin: 0; }

/* Paginação */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

/* JID compacto */
code.jid { font-size: .8rem; }

/* Mensagem completa */
pre.msg-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--pico-code-background-color);
  padding: 1rem;
  border-radius: .25rem;
  max-height: 500px;
  overflow-y: auto;
}

/* QR */
.qr-wrap {
  text-align: center;
  padding: 1rem;
}
.qr-wrap img {
  max-width: 320px;
  width: 100%;
  background: white;
  padding: .5rem;
  border-radius: .5rem;
}

/* Flash messages */
article.ok {
  background: rgba(0,212,170,.08);
  border: 1px solid rgba(0,212,170,.3);
  color: var(--accent);
  padding: .75rem 1rem;
}
article.error {
  background: rgba(255,123,123,.08);
  border: 1px solid rgba(255,123,123,.3);
  color: #ff7b7b;
  padding: .75rem 1rem;
}

article.pending-block {
  border-left: 4px solid #ffc800;
}
article.pending-block header strong { color: #ffc800; }

article.license-block { border-left: 4px solid var(--pico-muted-border-color); }
article.license-block.license-active  { border-left-color: var(--accent); }
article.license-block.license-expired { border-left-color: #ff7b7b; }
article.license-block header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.license-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.license-actions form, .license-actions button { margin: 0; }

/* Profile card na página do tenant */
.profile-card {
  margin-bottom: 1rem;
  border-left: 3px solid var(--pico-muted-border-color);
}
.profile-card.active {
  border-left-color: var(--accent);
}
.profile-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.profile-card .status-pill {
  font-size: .85rem;
  opacity: .8;
}
.profile-card details {
  margin-top: 1rem;
  padding: .5rem 0;
  border-top: 1px solid var(--pico-muted-border-color);
}
.profile-card details summary {
  cursor: pointer;
  padding: .3rem 0;
}
.profile-card form > label,
.profile-card form > .grid {
  margin-bottom: .75rem;
}

.new-profile-card {
  border-left: 3px dashed var(--accent);
  background: rgba(0, 212, 170, 0.03);
}

/* Page-header com 2 colunas (titulo + back) */
.page-header h1 { margin-bottom: .25rem; }
.page-header small { opacity: .7; }
