/* Bailder Infra: painel. Sem framework; tons quentes da marca, leitura densa. */
:root {
  --bg: #f6f3ee; --card: #fffdf9; --ink: #1d1b18; --muted: #6f6a62; --line: #e4ded4;
  --accent: #e8591a; --ok: #1f7a4d; --ok-bg: #e3f2ea; --warn: #8a5a00; --warn-bg: #fbf0d9;
  --bad: #a3271b; --bad-bg: #f9e2de; --muted-bg: #eeeae3; --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.45; }
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

.topbar { background: var(--ink); color: #f6f3ee; }
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { text-decoration: none; display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.topnav { display: flex; gap: 1rem; align-items: center; flex: 1; flex-wrap: wrap; }
.topnav a { text-decoration: none; opacity: .85; } .topnav a:hover { opacity: 1; }
.org-name { font-weight: 600; padding-right: .5rem; border-right: 1px solid #444; }
.admin-link { color: var(--accent); }
.usermenu { display: flex; gap: .75rem; align-items: center; font-size: .9rem; }
.usermenu form { display: inline; }
.link-button { white-space: nowrap; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }

.container { max-width: 1160px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash-notice { background: var(--ok-bg); color: var(--ok); }
.flash-alert { background: var(--bad-bg); color: var(--bad); }
.secret-once { background: var(--warn-bg); color: var(--warn); padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; word-break: break-all; }

.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; }
.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.5rem; font-weight: 650; margin-top: .2rem; }
.stat-note { color: var(--muted); font-size: .82rem; margin-top: .2rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
td .mono, td.mono { overflow-wrap: anywhere; } /* URL, chave, tipo de evento: quebra em qualquer ponto */
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.neg { color: var(--bad); } .pos { color: var(--ok); }

.badge { white-space: nowrap; display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-muted { background: var(--muted-bg); color: var(--muted); }

form .field { margin-bottom: .85rem; display: flex; flex-direction: column; gap: .3rem; }
label { font-size: .85rem; font-weight: 600; }
input[type=text], input[type=search], input[type=url], input[type=date], input[type=month], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%;
}
.btn, input[type=submit], button.btn { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: .55rem 1rem; background: var(--ink); color: #fff; text-decoration: none; display: inline-block; }
.btn-accent { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }

.auth { max-width: 400px; margin: 3rem auto; }
.auth .card { padding: 1.5rem; }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 8px; }
.empty { color: var(--muted); padding: 1rem 0; }
.event-type { font-family: ui-monospace, monospace; font-size: .85rem; }

/* Deploy: log em tempo real */
.deploy-log { background: #0f1115; color: #d7dae0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem;
  line-height: 1.45; padding: 1rem; border-radius: var(--radius); max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }
.keybox { font-family: ui-monospace, monospace; font-size: .78rem; background: var(--muted-bg); padding: .6rem .8rem; border-radius: 8px; word-break: break-all; }
.danger-zone { border: 1px solid var(--bad-bg); }

/* Observabilidade: gráficos, logs, abas */
.chart { margin: 0; }
.chart figcaption { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .25rem; }
.chart-title { font-weight: 600; font-size: .9rem; }
.chart-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-svg { width: 100%; height: 110px; display: block; background: var(--muted-bg); border-radius: 6px; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.chart-area { fill: var(--accent); opacity: .12; stroke: none; }
.chart-axis { display: flex; justify-content: space-between; margin-top: .2rem; }
.tabs { display: flex; gap: .35rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .85rem; }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.logs { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; line-height: 1.45; background: #0f1115; color: #d8dee9; border-radius: 8px; padding: .6rem .8rem; overflow-x: auto; max-height: 70vh; overflow-y: auto; }
.logs .log-line { white-space: pre-wrap; word-break: break-word; border-bottom: 1px solid #1c2028; padding: .1rem 0; }
.logs .log-time { color: #7b8496; }
.logs .log-ctr { color: #88c0d0; }
.logs .log-error { color: #ff8a80; }
.logs .log-warn { color: #ffd479; }
.logs .log-debug { color: #7b8496; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .4rem 0; border-bottom: 1px solid var(--line); }

/* Assistente (IA) */
.agent-msg { padding: .6rem .2rem; border-bottom: 1px solid #eee; }
.agent-msg:last-child { border-bottom: 0; }
.agent-user .agent-text { font-weight: 500; }
.agent-text p { margin: .25rem 0; }

/* Fatura imprimível */
.pix-box { font-family: ui-monospace, monospace; font-size: .75rem; word-break: break-all; background: #f6f6f6; padding: .5rem; border-radius: 6px; }
.pix-qr svg { width: 180px; height: 180px; }
/* Celular: o menu vira uma faixa rolável de uma linha, em vez de ocupar meia tela. */
@media (max-width: 640px) {
  .topbar-inner { gap: .4rem 1rem; padding: .55rem 1rem; }
  .topnav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: .9rem; padding-bottom: .25rem; white-space: nowrap; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .usermenu { margin-left: auto; }
  .card { overflow-x: auto; } /* tabela larga rola dentro do card, sem esticar a página */
}

@media print {
  .topbar, .no-print, .flash { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
