:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #f0f1f8; --border: #e3e5f0; --text: #161a33; --muted: #6b7191;
  --brand: #5b4bff; --brand-600: #4a3bea; --brand-soft: #eeecff; --accent: #12b886; --accent-soft: #e3f8f0;
  --warn: #f59f00; --warn-soft: #fff4dc; --danger: #e5484d; --danger-soft: #fdecec; --info: #2f80ed; --info-soft: #e7f0fd;
  --side: #12132b; --side-text: #aeb2d6; --side-active: #ffffff1c;
  --shadow: 0 1px 2px #1a1f4a0f, 0 6px 20px #1a1f4a0d;  --radius: 14px; --chat-bg: #efeae2; --bubble: #d9fdd3;
}
:root[data-theme="dark"] {
  --bg: #0d0e1f; --surface: #161830; --surface-2: #1d2040; --border: #2a2d52; --text: #eceefb; --muted: #9096bd;
  --brand: #7b6dff; --brand-600: #6a5bf5; --brand-soft: #25225a; --accent: #2ed3a0; --accent-soft: #11382f;
  --warn-soft: #3a2d0e; --danger-soft: #3b1a1d; --info-soft: #17304f; --side: #0a0b19; --shadow: 0 1px 2px #0006, 0 8px 24px #0005;
  --chat-bg: #0b141a; --bubble: #005c4b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e1f; --surface: #161830; --surface-2: #1d2040; --border: #2a2d52; --text: #eceefb; --muted: #9096bd;
    --brand: #7b6dff; --brand-600: #6a5bf5; --brand-soft: #25225a; --accent: #2ed3a0; --accent-soft: #11382f;
    --warn-soft: #3a2d0e; --danger-soft: #3b1a1d; --info-soft: #17304f; --side: #0a0b19; --shadow: 0 1px 2px #0006, 0 8px 24px #0005;
    --chat-bg: #0b141a; --bubble: #005c4b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #7b6dff, #12b886); display: grid; place-items: center; color: #fff; }
.logo-img { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #fff; border: 2px solid #ffffff66; box-shadow: 0 4px 14px #0006; flex: none; position: relative; }
.logo-img img { position: absolute; width: 92px; max-width: none; left: -19px; top: -3px; }
/* Marca d'água: foto de fundo bem suave atrás do conteúdo */
.main { position: relative; isolation: isolate; }
.main::before { content: ""; position: fixed; right: 0; bottom: 0; width: min(760px, 70vw); height: min(760px, 85vh); z-index: -1; pointer-events: none; background: url(/brand/mascote.webp) right bottom / contain no-repeat; opacity: .13; }
:root[data-theme="dark"] .main::before { opacity: .16; mix-blend-mode: screen; }
@media (max-width: 1000px) { .main::before { width: 90vw; opacity: .10; } }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--side-text); font-weight: 500; transition: .15s; }
.nav a:hover { background: #ffffff10; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; color: #6d72a0; }
.side-foot { margin-top: auto; border-top: 1px solid #ffffff14; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; font-weight: 600; color: #fff; flex: none; }
.user-chip small { display: block; color: var(--side-text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.side-actions { display: flex; gap: 8px; }
.side-actions .btn { flex: 1; background: #ffffff12; color: #dfe1ff; border: 0; }
.side-actions .btn:hover { background: #ffffff22; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.content { padding: 28px 32px 60px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); gap: 12px; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-2 { grid-template-columns: 1.6fr 1fr; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: center; }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .ic svg { width: 22px; height: 22px; }
.stat .v { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 13px; }
.tone-brand { background: var(--brand-soft); color: var(--brand); } .tone-ok { background: var(--accent-soft); color: var(--accent); }
.tone-warn { background: var(--warn-soft); color: var(--warn); } .tone-bad { background: var(--danger-soft); color: var(--danger); } .tone-info { background: var(--info-soft); color: var(--info); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; transition: .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 14px #5b4bff40; }
.btn.primary:hover { background: var(--brand-600); }
.btn.success { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.success:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); } .btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 8px; }
.btn.block { width: 100%; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { background: var(--accent-soft); color: var(--accent); } .b-warn { background: var(--warn-soft); color: #c98200; }
.b-bad { background: var(--danger-soft); color: var(--danger); } .b-info { background: var(--info-soft); color: var(--info); }
.b-mute { background: var(--surface-2); color: var(--muted); } .b-brand { background: var(--brand-soft); color: var(--brand); }
:root[data-theme="dark"] .b-warn { color: var(--warn); }

label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13.5px; }
label.f small { color: var(--muted); font-weight: 400; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); outline: none; transition: .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #5b4bff25; }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--brand); width: 16px; height: 16px; }
.hint { color: var(--muted); font-size: 13px; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: var(--warn-soft); color: #8a5a00; } .alert.info { background: var(--info-soft); color: var(--info); } .alert.bad { background: var(--danger-soft); color: var(--danger); } .alert.ok { background: var(--accent-soft); color: #0b7f5c; }
:root[data-theme="dark"] .alert.warn { color: var(--warn); } :root[data-theme="dark"] .alert.ok { color: var(--accent); }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 11px 16px; background: var(--surface-2); }
.t td { padding: 13px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.t tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.t-wrap { overflow-x: auto; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 11px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; display: flex; }
.progress > i { display: block; height: 100%; transition: width .4s; }
.p-read { background: var(--accent); } .p-deliv { background: #5fd3b0; } .p-sent { background: var(--brand); } .p-fail { background: var(--danger); } .p-skip { background: #b7bbd6; }

.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .big { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .big svg { width: 30px; height: 30px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; height: 90px; }
@keyframes sk { to { background-position: -200% 0; } }
.spin { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: #0b0d2299; backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; z-index: 100; animation: fade .15s; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); box-shadow: 0 30px 80px #0008; border: 1px solid var(--border); animation: pop .18s; }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; max-width: 380px; animation: pop .2s; }
.toast.ok svg { color: var(--accent); } .toast.err { background: var(--danger); color: #fff; }

/* ---------- Specific ---------- */
.conn { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.conn-top { display: flex; gap: 14px; align-items: center; }
.conn-ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff; flex: none; }
.conn-ic.evolution { background: linear-gradient(135deg, #12b886, #0b7f5c); } .conn-ic.meta { background: linear-gradient(135deg, #2f80ed, #1c4fb8); }
.conn h3 { font-size: 16px; }
.conn-meta { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.conn-actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; }
.copybox { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 8px; padding: 6px 6px 6px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.type-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-opt { border: 2px solid var(--border); border-radius: 14px; padding: 16px; cursor: pointer; transition: .15s; display: flex; flex-direction: column; gap: 6px; background: var(--surface); text-align: left; }
.type-opt:hover { border-color: var(--brand); } .type-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.qr-box { display: grid; place-items: center; padding: 14px; }
.qr-box img { width: 260px; height: 260px; image-rendering: pixelated; background: #fff; padding: 10px; border-radius: 14px; border: 1px solid var(--border); }
.split { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.list-item:hover { background: var(--surface-2); } .list-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.steps { display: flex; gap: 8px; margin-bottom: 4px; }
.step { flex: 1; height: 5px; border-radius: 9px; background: var(--border); } .step.done { background: var(--brand); }
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 36px; text-align: center; cursor: pointer; color: var(--muted); transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface-2); border-radius: 99px; padding: 3px 11px; font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.campaign-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 20px; }
.phone { border-radius: 26px; border: 8px solid #1d1f3a; background: var(--chat-bg); overflow: hidden; box-shadow: var(--shadow); }
.phone-top { background: #075e54; color: #fff; padding: 12px 14px; display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; }
.phone-top .avatar { width: 30px; height: 30px; background: #25d366; font-size: 13px; }
.phone-body { padding: 16px 12px; min-height: 280px; display: flex; flex-direction: column; justify-content: flex-start; gap: 6px; }
.bubble { background: var(--bubble); color: #111b21; border-radius: 10px 10px 2px 10px; padding: 8px 11px; max-width: 92%; align-self: flex-end; white-space: pre-wrap; word-break: break-word; font-size: 14px; box-shadow: 0 1px 1px #0002; }
:root[data-theme="dark"] .bubble { color: #e9edef; }
.bubble img.m { width: 100%; border-radius: 6px; margin-bottom: 6px; display: block; }
.bubble .t { font-size: 11px; color: #667781; text-align: right; margin-top: 3px; }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding: 6px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--brand), #9a8fff); border-radius: 8px 8px 3px 3px; min-height: 3px; transition: height .4s; }
.bar-col span { font-size: 12px; color: var(--muted); } .bar-col b { font-size: 12px; }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: radial-gradient(1200px 600px at 20% 10%, #7b6dff55, transparent), linear-gradient(160deg, #12132b, #1d1a55 60%, #0b7f5c); position: relative; overflow: hidden; color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero h2 { font-size: 38px; line-height: 1.12; max-width: 460px; letter-spacing: -0.03em; }
.login-hero ul { list-style: none; padding: 0; display: grid; gap: 12px; color: #d3d6f5; }
.login-hero li { display: flex; gap: 10px; align-items: center; }
.login-form { display: grid; place-items: center; padding: 30px; }
.login-form form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 60; width: 264px; transform: translateX(-100%); transition: .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax #0006; }
  .topbar { display: flex; } .content { padding: 20px 16px 50px; }
  .grid.cols-2, .campaign-layout, .split, .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; } .sticky { position: static; } .form-grid, .type-pick { grid-template-columns: 1fr; }
}

.form-mascot { height: 230px; align-self: center; border-radius: 22px; background: #fff; padding: 8px; object-fit: contain; box-shadow: var(--shadow); }
