:root {
  --bg: #0a0c10;
  --panel: #10131a;
  --panel-2: #151923;
  --line: #1f2531;
  --text: #e7eaf0;
  --muted: #8a93a6;
  --accent: #2ee59d;
  --accent-ink: #04150d;
  --warn: #f5b84b;
  --danger: #ff5d6c;
  --info: #6aa8ff;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #12202a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; font-size: 16px; }
.brand.big { font-size: 22px; }
.logo { color: var(--accent); }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: rgba(12,14,19,.75); backdrop-filter: blur(10px); padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.sidebar nav a:hover { background: var(--panel-2); color: var(--text); }
.sidebar nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.3px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* Cards */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: linear-gradient(180deg, var(--panel) 0%, #0e1117 100%); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--accent); border-color: rgba(46,229,157,.25); background: rgba(46,229,157,.08); }
.badge.warn { color: var(--warn); border-color: rgba(245,184,75,.25); background: rgba(245,184,75,.08); }
.badge.bad { color: var(--danger); border-color: rgba(255,93,108,.25); background: rgba(255,93,108,.08); }
.badge.info { color: var(--info); border-color: rgba(106,168,255,.25); background: rgba(106,168,255,.08); }

/* Buttons & inputs */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; }
.btn:hover { border-color: #2c3443; background: #1a1f2b; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; background: #0b0e14; border: 1px solid var(--line); color: var(--text); padding: 10px 12px; border-radius: 10px; font: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #2e7d5f; box-shadow: 0 0 0 3px rgba(46,229,157,.12); }
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); }
.check input { width: auto; }
.form { display: grid; gap: 14px; }
.form .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Lists & tables */
.list { display: grid; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { min-width: 0; flex: 1; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: rgba(255,255,255,.015); }
details summary { cursor: pointer; color: var(--muted); }
pre { white-space: pre-wrap; word-break: break-word; background: #0b0e14; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 8px 0 0; max-height: 320px; overflow: auto; }

/* QR */
.qr-box { display: grid; place-items: center; background: #fff; border-radius: 16px; padding: 14px; width: 300px; max-width: 100%; aspect-ratio: 1; }
.qr-box img { width: 100%; height: auto; image-rendering: pixelated; }
.wa-profile { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); object-fit: cover; }

/* Chat */
.chat { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - 170px); min-height: 420px; }
.chat-log { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 16px; }
.bubble { max-width: min(720px, 85%); padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line); }
.bubble.user { align-self: flex-end; background: #11372a; border-color: #1c5440; }
.bubble.assistant { align-self: flex-start; background: var(--panel-2); }
.bubble.tool { align-self: flex-start; background: transparent; color: var(--muted); font-size: 12px; border-style: dashed; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; }
.bubble.media { padding: 6px; max-width: min(520px, 85%); }
.bubble.media img { display: block; width: 100%; border-radius: 10px; }
.bubble.media div { padding: 8px 8px 4px; }
.bubble code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.wa-pre { margin: 6px 0; max-height: none; }
.wa-quote { display: block; border-left: 3px solid var(--accent); padding-left: 8px; color: var(--muted); }
.chat-input { display: flex; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.chat-input textarea { min-height: 48px; height: 48px; }
.typing { color: var(--muted); font-size: 12px; }

/* Integrations */
.integration { display: grid; gap: 12px; }
.integration .title { font-weight: 700; font-size: 16px; }
.tools-list { max-height: 260px; overflow: auto; display: grid; gap: 4px; margin-top: 8px; }
.tool-chip { font-size: 12px; padding: 6px 8px; background: #0b0e14; border: 1px solid var(--line); border-radius: 8px; }

/* Espaçamento entre seções */
.main > .grid + .grid, .main > .grid + .card, .main > .card + .grid, .main > .card + .card { margin-top: 16px; }
.notice { border-color: rgba(245,184,75,.35); }
.notice a { text-decoration: underline; }

/* Toast */
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 420px; z-index: 50; }
.toast.bad { border-color: rgba(255,93,108,.4); }
.toast.ok { border-color: rgba(46,229,157,.4); }

@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; padding: 12px 16px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; overflow-x: auto; gap: 4px; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-foot { flex-direction: row; display: flex; align-items: center; justify-content: space-between; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 48px; }
  .chat { height: calc(100vh - 260px); }
}

/* Criativos */
.stackbar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--panel-2); margin: 10px 0; }
.stackbar .seg { display: block; height: 100%; background: var(--info); }
.seg-postado, .seg-pronto { background: var(--accent) !important; }
.seg-falhou, .seg-sem_conta { background: var(--danger) !important; }
.seg-bloqueado, .seg-descartado { background: #4b5263 !important; }
.seg-em_revisao { background: var(--warn) !important; }
td.pre { white-space: pre-wrap; max-width: 420px; }
.pre-line { white-space: pre-line; }
.daybars { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 14px; }
.daybar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.daybar span { display: block; width: 100%; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.daybar small { color: var(--muted); font-size: 10px; }

#pr-form select, #pr-form input:not([type=checkbox]) { width: auto; min-width: 140px; }
.print-img { display: block; max-width: 460px; width: 100%; border-radius: 12px; border: 1px solid var(--line); margin-top: 12px; }
