:root {
  --bg: #f4f6fb;
  --side: #0d1424;
  --side-2: #161f33;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e9f2;
  --blue: #2563eb;
  --blue-d: #1d4ed8;
  --green: #10b981;
  --green-bg: #d1fae5;
  --orange: #f97316;
  --orange-bg: #ffedd5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ----- Login ----- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 360px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

/* ----- App layout ----- */
.app { display: none; min-height: 100vh; grid-template-columns: 248px 1fr; }
.app.show { display: grid; }

.side { background: var(--side); color: #cbd5e1; padding: 18px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; padding: 6px 8px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--blue), #22d3ee); display: grid; place-items: center; font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; color: #cbd5e1; font-size: 14px; font-weight: 500; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--blue); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.side .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 8px; }
.userbox .av { width: 34px; height: 34px; border-radius: 50%; background: var(--side-2); display: grid; place-items: center; color: #fff; font-weight: 700; }
.userbox .nm { font-size: 13px; color: #fff; }
.userbox .rl { font-size: 11px; color: #94a3b8; }
.userbox .out { margin-left: auto; color: #94a3b8; background: none; border: 0; padding: 6px; border-radius: 8px; }
.userbox .out:hover { color: #fff; background: var(--side-2); }

/* ----- Main ----- */
.main { padding: 28px 32px; overflow: auto; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; gap: 7px; }
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
h2.title { margin: 6px 0 4px; font-size: 32px; letter-spacing: -.02em; }
.subtitle { color: var(--muted); margin: 0 0 22px; font-size: 15px; }

.bar { background: #eef4ff; border: 1px solid #dbe7ff; border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; color: #1e40af; font-size: 14px; margin-bottom: 16px; }
.bar b { font-variant-numeric: tabular-nums; }
.bar .right { margin-left: auto; color: var(--muted); font-size: 12px; }

.panel { background: #eff5ff; border: 1px solid #dce8ff; border-radius: 14px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.panel .pic { width: 44px; height: 44px; border-radius: 12px; background: #dbeafe; display: grid; place-items: center; font-size: 20px; }
.panel h3 { margin: 0; font-size: 16px; }
.panel p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.panel .acts { margin-left: auto; display: flex; gap: 10px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.tabs { display: inline-flex; background: #eef2f9; border-radius: 999px; padding: 4px; gap: 2px; }
.tabs button { border: 0; background: none; padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: #0f172a; color: #fff; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; }
.search input { border: 0; outline: 0; flex: 1; font-size: 14px; background: none; }
.count-chip { color: var(--muted); font-size: 13px; white-space: nowrap; }
.minads { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.minads input { width: 56px; border: 1px solid var(--line); outline: 0; border-radius: 8px; padding: 5px 8px; font-size: 14px; font-weight: 700; color: var(--ink); text-align: center; }
.minads input:focus { border-color: var(--blue); }

.destfilter { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.destfilter select { border: 1px solid var(--line); outline: 0; border-radius: 8px; padding: 5px 8px; font-size: 13px; font-weight: 700; color: var(--ink); background: #fff; cursor: pointer; }
.destfilter select:focus { border-color: var(--blue); }

/* Selo de destino do anúncio no card */
.destbadge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--line); color: var(--muted); background: #f8fafc; }
.destbadge.dest-site { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.destbadge.dest-whatsapp { color: #065f46; background: #d1fae5; border-color: #a7f3d0; }
.destbadge.dest-mensagem { color: #92400e; background: #fef3c7; border-color: #fde68a; }
.destbadge.dest-instagram { color: #9d174d; background: #fce7f3; border-color: #fbcfe8; }
.destbadge.dest-outro { color: var(--muted); background: #f1f5f9; }

/* ----- Buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600; border: 1px solid transparent; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f8fafc; }
.btn.sm { padding: 8px 12px; font-size: 13px; }

/* ----- Cards grid ----- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--green); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; }
.card .head { display: flex; align-items: flex-start; gap: 12px; }
.card .av { width: 42px; height: 42px; border-radius: 12px; background: #eef2ff; color: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.card .nm { font-weight: 700; font-size: 16px; line-height: 1.2; }
.badge { font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 4px 8px; border-radius: 6px; background: var(--green-bg); color: #047857; }
.pill { display: inline-flex; align-items: center; gap: 5px; background: var(--orange-bg); color: #c2410c; font-weight: 700; font-size: 13px; padding: 5px 10px; border-radius: 8px; margin-top: 10px; width: fit-content; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { background: #f1f5f9; color: #475569; font-size: 12px; padding: 4px 9px; border-radius: 7px; }
.note { color: var(--muted); font-size: 13px; margin-top: 12px; }
.card .foot { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.card .row { display: flex; gap: 8px; }
.card .row .btn { flex: 1; }
.iconbtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--muted); display: grid; place-items: center; font-size: 14px; }
.iconbtn:hover { background: #f8fafc; color: var(--ink); }
.icons { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }

/* ----- SaaS metrics ----- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.metric { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
.metric .k { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.metric .v { font-size: 15px; font-weight: 800; margin-top: 2px; }
.mrr { margin-left: auto; text-align: right; }
.mrr .k { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.mrr .v { font-size: 22px; font-weight: 800; color: var(--green); }

/* ----- Monitorando rows ----- */
.mon { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.mon .r { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.mon .r:last-child { border-bottom: 0; }
.mon .r .nm { font-weight: 600; min-width: 180px; }
.mon .r .now { font-weight: 800; font-size: 18px; margin-left: auto; }
.delta { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.delta.up { background: var(--green-bg); color: #047857; }
.delta.down { background: #fee2e2; color: #b91c1c; }
.delta.flat { background: #f1f5f9; color: #64748b; }

/* ----- Detail ----- */
.back { color: var(--muted); font-size: 14px; margin-bottom: 16px; display: inline-flex; gap: 6px; }
.detail-head { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); display: flex; gap: 16px; align-items: flex-start; }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.statgrid .metric .v { font-size: 22px; }
.chartbox { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.chartbox h3 { margin: 0 0 14px; }

/* ----- Forms / modal ----- */
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: 0; background: var(--card); }
.input:focus { border-color: var(--blue); }
label.fld { display: block; margin-bottom: 12px; }
label.fld span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #334155; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; place-items: center; padding: 24px; z-index: 50; }
.modal-bg.show { display: grid; }
.modal { background: var(--card); border-radius: 16px; width: 100%; max-width: 620px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal header { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal header h3 { margin: 0; font-size: 18px; }
.modal header .x { margin-left: auto; background: none; border: 0; font-size: 22px; color: var(--muted); }
.modal .body { padding: 20px 22px; }
.modal footer { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .app.show { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .spacer, .userbox { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .metrics, .statgrid { grid-template-columns: repeat(2, 1fr); }
}
