:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2433; --muted: #6b7486; --line: #e3e7ee;
  --primary: #1f8f5f; --primary-2: #17744d; --danger: #c43d3d; --warn-bg: #fff6e0; --warn: #8a6100;
  --side: #10241b; --side-text: #cfe3d8; --bubble: #dcf8c6; --chat: #ece5dd;
  --ok: #1f8f5f; --err: #c43d3d; --skip: #8a8f99;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --card: #1b2129; --text: #e6e9ee; --muted: #9aa3b2; --line: #2b333e;
    --warn-bg: #2e2716; --warn: #e6c46e; --side: #0b1712; --bubble: #1f4a34; --chat: #0f1a14;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
#app { display: flex; min-height: 100vh; }
.side { width: 230px; background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-size: 22px; font-weight: 800; color: #fff; padding: 0 10px 18px; }
.brand span { color: #4fd18f; }
nav a { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--side-text); user-select: none; }
nav a:hover { background: rgba(255,255,255,.06); }
nav a.active { background: rgba(79,209,143,.16); color: #fff; font-weight: 600; }
.pill { background: #e2a400; color: #000; border-radius: 99px; padding: 0 7px; font-size: 11px; margin-left: auto; }
.conn { margin-top: auto; font-size: 12px; padding: 10px; display: grid; gap: 6px; }
.me-box { font-size: 12px; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.me-box a { color: #8fd9b3; cursor: pointer; }
.audit { font-size: 11px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--skip); }
.dot.on { background: #4fd18f; } .dot.wait { background: #e2a400; } .dot.off { background: #d65b5b; }
main { flex: 1; padding: 24px 28px 60px; min-width: 0; max-width: 1400px; }
h2 { margin: 0 0 16px; } h3 { margin: 0 0 12px; font-size: 15px; }
.tab { display: none; } .tab.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.grid3 > .card { margin-bottom: 0; }
.auto-card { border-color: var(--primary); background: linear-gradient(0deg, var(--card), var(--card)), var(--card); }
.auto-card .row .btn, .auto-card .row .radio { margin-bottom: 0; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre; font-size: 11px; }
details summary { cursor: pointer; margin: 6px 0; }
.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.list-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.list-item.active { border-color: var(--primary); background: rgba(31,143,95,.08); }
.list-item .row { gap: 4px; }
.list-item .btn { margin: 0; }
.pk-lists { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pk-lists label { margin: 0; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; color: var(--text); cursor: pointer; }
.pk-lists input { width: auto; margin: 0; }
.pk-lists label:has(input:checked) { border-color: var(--primary); background: rgba(31,143,95,.12); }
.sellers td { padding: 4px; }
.sellers input[type=text], .sellers input[type=tel] { margin: 0; padding: 6px 8px; }
.bulk { padding: 8px 10px; background: var(--bg); border-radius: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.table input[type=checkbox] { width: auto; margin: 0; }
.grid2 > .card { margin-bottom: 0; } .grid2 + .card, section > .grid2 { margin-bottom: 18px; }
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(31,143,95,.35); border-color: var(--primary); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 140px; }
.row > .radio, .radio { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; color: var(--text); }
.radio input { width: auto; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; font: inherit; font-weight: 600; margin-bottom: 12px; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); } .btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12px; margin: 0; }
.btn:disabled { opacity: .55; cursor: wait; }
.filebtn { position: relative; overflow: hidden; color: var(--text); }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--err); }
.stack { display: grid; gap: 10px; }
.copy-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; white-space: pre-wrap; }
.copy-item .btn { margin: 8px 0 0; }
.refzone { border: 2px dashed var(--line); border-radius: 10px; padding: 10px; margin-bottom: 12px; transition: border-color .15s, background .15s; }
.refzone.drag { border-color: var(--primary); background: rgba(31,143,95,.08); }
.refzone-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.refzone-head .btn { margin: 0; color: var(--text); }
.refzone input[type=file] { display: none; }
.refzone .thumbs:empty { display: none; }
.refzone .thumbs:not(:empty) + .refzone-empty { display: none; }
.thumb { position: relative; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; padding: 0; cursor: pointer; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; position: relative; }
.gallery figure.sel { border-color: var(--primary); }
.gallery figure.sel::after { content: "✓ selecionada"; position: absolute; left: 6px; top: 6px; background: var(--primary); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.gallery img { width: 100%; display: block; }
.phone { background: var(--chat); border-radius: 12px; padding: 16px; min-height: 240px; }
.bubble { background: var(--bubble); border-radius: 10px; padding: 6px; max-width: 360px; box-shadow: 0 1px 1px rgba(0,0,0,.12); white-space: pre-wrap; word-break: break-word; }
.bubble img { width: 100%; border-radius: 8px; display: block; margin-bottom: 6px; }
.bubble .txt { padding: 2px 6px 4px; }
.bubble:empty { display: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.cards .card { margin: 0; display: flex; flex-direction: column; }
.camp-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 10px; }
.camp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 12px; }
.status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.status.draft { background: #fff1c2; color: #7a5a00; }
.status.approved { background: #d4f5e3; color: #11643f; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 160px; margin: 0; }
.filters .btn { margin: 0; }
.table { width: 100%; border-collapse: collapse; }
.card:has(> .table) { overflow-x: auto; }
main > section, .grid2 > *, .grid3 > * { min-width: 0; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { margin-left: 4px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.tag.wa { color: #128c4b; } .tag.tg { color: #1f7fc4; }
.tag.ok { color: var(--ok); } .tag.erro { color: var(--err); } .tag.ignorado { color: var(--skip); } .tag.out { color: var(--err); }
.days { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.days label { margin: 0; }
.days input { display: none; }
.days span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--text); }
.days input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.picker { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 6px 0 14px; }
.picker .filters { margin-bottom: 8px; }
.picker-list { max-height: 260px; overflow: auto; display: grid; gap: 2px; }
.picker-list label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 5px 6px; border-radius: 6px; color: var(--text); cursor: pointer; }
.picker-list label:hover { background: var(--bg); }
.picker-list input { width: auto; margin: 0; }
.picker-list .disabled { opacity: .5; }
.sched { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 0; }
.sched .meta { display: grid; gap: 2px; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.qr { background: #fff; padding: 10px; border-radius: 10px; display: inline-block; }
.qr img { display: block; width: 260px; height: 260px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-box { width: 100%; max-width: 620px; max-height: 90vh; overflow: auto; margin: 0; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #1d2433; color: #fff; padding: 12px 16px; border-radius: 10px; z-index: 60; max-width: 420px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); }
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; }
.login-card h1 { margin: 0 0 6px; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1250px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  #app { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; padding: 10px; }
  .brand { padding: 4px 10px 10px; }
  nav { display: flex; overflow-x: auto; gap: 4px; }
  nav a { white-space: nowrap; }
  .conn { display: none; }
  main { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}
