/* ============================================================
   POSTYPE — Painel admin
   Tema escuro refinado · Inter · tokens · mobile-first
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --bg-elev: #141414;
  --bg-elev-2: #1c1c1c;
  --bg-hover: #1a1a1a;
  --border: #262626;
  --border-subtle: #1f1f1f;
  --text: #fafafa;
  --text-dim: #a3a3a3;
  --text-faint: #737373;
  --text-muted: #525252;
  --success: #00dc82;
  --success-bg: rgba(0,220,130,0.1);
  --danger: #f05252;
  --danger-bg: rgba(240,82,82,0.1);
  --warning: #facc15;
  --warning-bg: rgba(250,204,21,0.1);
  --info: #3b82f6;
  --info-bg: rgba(59,130,246,0.1);
  --violet: #a78bfa;
  --violet-bg: rgba(139,92,246,0.1);
  --brand: #e8265b;
  --brand-2: #b81d49;
  --brand-bg: rgba(232,38,91,0.12);
  --gold: #D4A843;
  --sidebar-width: 240px;
  --radius: 10px;
  --radius-sm: 7px;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
code, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #333; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 28% 18%, rgba(232,38,91,0.10), transparent 55%),
    radial-gradient(ellipse at 75% 85%, rgba(0,220,130,0.04), transparent 55%),
    var(--bg);
}
.login-box {
  width: 100%;
  max-width: 380px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
}
.login-title {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 5px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 26px;
}
.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 24px;
}
.login-help {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

/* ============================================================
   BRAND LOGO
   ============================================================ */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}
.logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.logo-text em {
  font-style: normal;
  color: var(--text-dim);
  font-weight: 500;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-head {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
}
.nav-label {
  padding: 8px 10px 6px;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  transition: background .12s, color .12s;
  position: relative;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--bg-elev);
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}
.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--border-subtle);
}
.nav-item.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* mobile topbar toggle */
.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 60;
  height: 54px;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.mobile-burger {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 56px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   PAGE HEADER / TOOLBAR
   ============================================================ */
.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-sub {
  font-size: 13px;
  color: var(--text-dim);
}
.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, transform .08s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.985); }
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: #f0356b; }

.btn-light {
  background: var(--text);
  color: #000;
}
.btn-light:hover { background: #e5e5e5; }

.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(240,82,82,0.25);
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(240,82,82,0.18);
}

/* ============================================================
   CARDS / PANELS
   ============================================================ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.panel-head {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-sub {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
  margin-bottom: 18px;
}

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-dim);
  font-size: 14px;
  border-style: dashed;
}
.empty strong { color: var(--text); }

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.pill-on {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(0,220,130,0.22);
}
.pill-off {
  background: rgba(115,115,115,0.12);
  color: var(--text-faint);
  border-color: var(--border);
}
.pill-info {
  background: var(--info-bg);
  color: #6ea8fe;
  border-color: rgba(59,130,246,0.22);
}
.pill-brand {
  background: var(--brand-bg);
  color: #ff7197;
  border-color: rgba(232,38,91,0.25);
}

/* ============================================================
   FUNIS — grid de cards
   ============================================================ */
.funil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}
.funil-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color .15s, background .15s;
}
.funil-card:hover {
  border-color: #383838;
  background: var(--bg-elev-2);
}
.fc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.fc-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.fc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 7px;
}
.fc-model {
  font-size: 12px;
  color: var(--text-faint);
}
.fc-linkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 8px 7px 11px;
}
.fc-link {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.copy-btn { flex-shrink: 0; }
.fc-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}
.fc-actions form { display: inline-flex; }
.fc-actions .btn { flex: 0 0 auto; }

/* ============================================================
   FORM / EDITOR
   ============================================================ */
.form-section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}
.form-section h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.form-section h3::before {
  content: '';
  width: 3px;
  height: 15px;
  background: var(--brand);
  border-radius: 2px;
}
.sec-sub {
  font-size: 12.5px;
  color: var(--text-faint);
  margin: 6px 0 18px 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field:last-child { margin-bottom: 0; }
.field label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}
.field .hint {
  color: var(--text-muted);
  font-weight: 400;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color .14s, background .14s;
}
.field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: #4a4a4a;
  background: var(--bg-elev-2);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.grid .field,
.grid-3 .field { margin-bottom: 0; }
.grid + .grid,
.grid-3 + .grid,
.grid + .field,
.grid-3 + .field,
.field + .grid,
.field + .grid-3 { margin-top: 14px; }
.full { grid-column: 1 / -1; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  user-select: none;
}
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.subcard {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-top: 16px;
}
.subcard h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.subcard h4 .tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-elev-2);
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
.subcard h4.vip .tag { background: var(--warning-bg); color: var(--gold); }
.subcard .field { margin-bottom: 14px; }
.subcard .grid + .field,
.subcard .grid-3 + .field,
.subcard .field + .grid,
.subcard .check + .grid-3 { margin-top: 14px; }

.form-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  margin-top: 6px;
}
.form-bar-inner {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-subtle);
  padding: 14px 0;
}

code.urltag {
  color: var(--gold);
  font-size: 12px;
}

/* ============================================================
   DASHBOARD — filtros
   ============================================================ */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.filters select {
  padding: 9px 34px 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.filters select:focus { outline: none; border-color: #4a4a4a; }
.filters select:first-child { min-width: 220px; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s;
}
.kpi-card:hover { border-color: #383838; }
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--text-faint);
}
.kpi-card.k-blue::after { background: var(--info); }
.kpi-card.k-gold::after { background: var(--gold); }
.kpi-card.k-green::after { background: var(--success); }
.kpi-card.k-brand::after { background: var(--brand); }
.kpi-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 9px 0 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-foot {
  font-size: 12px;
  color: var(--text-faint);
}
.kpi-foot b { color: var(--text-dim); font-weight: 600; }

/* ============================================================
   FUNNEL — jornada do lead
   ============================================================ */
.funnel {
  display: flex;
  flex-direction: column;
}
.fstep {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}
.fstep-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.fstep-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.fstep-count {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.fstep-bar {
  height: 8px;
  background: var(--bg-elev-2);
  border-radius: 100px;
  overflow: hidden;
}
.fstep-fill {
  height: 100%;
  border-radius: 100px;
  transition: width .5s ease;
  min-width: 4px;
}
.fstep-pct {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 7px;
}
.fdrop {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--text-faint);
}
.fdrop .arrow {
  width: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.fdrop b {
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
}
.fdrop .lost {
  color: var(--danger);
  font-weight: 500;
}
.conv-ok   { color: var(--success); background: var(--success-bg); }
.conv-mid  { color: var(--warning); background: var(--warning-bg); }
.conv-bad  { color: var(--danger);  background: var(--danger-bg); }

/* ============================================================
   STAT CARDS (cliques por oferta / chamada)
   ============================================================ */
.offer-grid,
.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.sc-name {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
}
.sc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sc-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
}
.sc-foot {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ============================================================
   NOTE / ALERT
   ============================================================ */
.note {
  background: var(--info-bg);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-top: 18px;
}
.note b { color: var(--text); }

.alert {
  background: var(--danger-bg);
  border: 1px solid rgba(240,82,82,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: #ff8585;
  margin-bottom: 16px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1000px) {
  .main { padding: 24px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .mobile-bar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .26s ease;
    box-shadow: 12px 0 32px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-backdrop { display: block; }
  .main { padding: 20px 16px 48px; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .offer-grid,
  .mini-grid { grid-template-columns: 1fr; }
  .grid,
  .grid-3 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .page-title { font-size: 20px; }
  .form-section,
  .panel { padding: 18px 16px; }
  .fstep-count { font-size: 17px; }
  .kpi-value { font-size: 24px; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
