/* =========================================
   intimity.fun · estilo
   Dark, refinado, com acentos de cassino.
   ========================================= */

:root {
  /* Cores */
  --bg:         #0a0a0b;
  --bg-grain:   radial-gradient(1200px 600px at 10% -10%, rgba(251,191,36,.04), transparent 60%),
                radial-gradient(900px 500px at 100% 0%, rgba(74,222,128,.03), transparent 60%);
  --surface:    #111113;
  --surface-2:  #17171a;
  --surface-3:  #1c1c20;
  --border:     #26262b;
  --border-2:   #2e2e34;

  --text:       #f5f5f4;
  --text-2:     #d6d3d1;
  --muted:      #a1a1a6;
  --dim:        #6b6b73;

  --accent:     #fbbf24;   /* âmbar/dourado */
  --accent-2:   #f59e0b;
  --pos:        #4ade80;   /* lime */
  --pos-bg:     rgba(74,222,128,.08);
  --neg:        #f87171;   /* coral */
  --neg-bg:     rgba(248,113,113,.08);
  --info:       #60a5fa;
  --info-bg:    rgba(96,165,250,.08);

  /* Tipografia */
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Layout */
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  18px;
  --shadow:     0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px -10px rgba(0,0,0,.6);
  --gutter:     24px;
  --maxw:       1280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grain);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Tipografia ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.015em;
  margin: 0 0 .5em;
  color: var(--text);
}
h1 { font-size: 2rem; letter-spacing: -.03em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.dim   { color: var(--dim); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 16px 32px;
  background: rgba(17,17,19,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.brand-link:hover { color: var(--text); }
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 24px rgba(251,191,36,.4);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(.85); opacity: .65; }
}
.brand-tld { color: var(--accent); font-weight: 500; }

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  font-size: .92rem;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--surface-2); }

.user-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .9rem;
}
.user-name {
  color: var(--muted);
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.logout {
  color: var(--muted);
  font-weight: 500;
}
.logout:hover { color: var(--neg); }

/* ---------- Container ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px var(--gutter) 80px;
}

/* ---------- Flash messages ---------- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-weight: 500;
  border: 1px solid;
}
.flash-success {
  background: var(--pos-bg);
  color: var(--pos);
  border-color: rgba(74,222,128,.25);
}
.flash-error {
  background: var(--neg-bg);
  color: var(--neg);
  border-color: rgba(248,113,113,.25);
}

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; }
.page-head .subtitle { color: var(--muted); margin-top: 4px; font-size: .95rem; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Cards / KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-2), transparent);
}
.kpi-label {
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-meta {
  margin-top: 6px;
  font-size: .82rem;
  color: var(--dim);
}
.kpi.featured {
  background: linear-gradient(180deg, rgba(251,191,36,.06), transparent 60%), var(--surface);
  border-color: rgba(251,191,36,.25);
}
.kpi.featured .kpi-value { color: var(--accent); }

/* ---------- Cards genéricos ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card + .card { margin-top: 20px; }

/* ---------- Filtros ---------- */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 20px;
}
.filters .field { margin: 0; }
.filters .period-chips {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}
.period-chip {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .85rem;
  color: var(--muted);
  font-weight: 500;
}
.period-chip:hover { color: var(--text); }
.period-chip.active { background: var(--accent); color: #1a1a1a; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-3); border-color: var(--dim); color: var(--text); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent-2);
  color: #1a1a1a;
}
.btn-primary:hover { background: var(--accent-2); color: #1a1a1a; }
.btn-danger {
  background: transparent;
  border-color: rgba(248,113,113,.3);
  color: var(--neg);
}
.btn-danger:hover { background: var(--neg-bg); border-color: var(--neg); color: var(--neg); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 20px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
}
.field { display: grid; gap: 6px; }
.field label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 500;
}
/* Label com link à direita (ex: "+ nova") */
.field label.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.label-link {
  text-transform: none;
  letter-spacing: 0;
  font-size: .75rem;
  color: var(--accent);
  font-weight: 500;
}
.label-link:hover { color: var(--accent-2); }
.field input,
.field select,
.field textarea {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: .95rem;
  transition: border-color .15s, background .15s;
}
.field input.num,
.field input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.field textarea { min-height: 80px; resize: vertical; }
.field-hint { font-size: .78rem; color: var(--dim); }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Calculadora ao vivo no form de remessa */
.live-calc {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
}
.live-calc .calc {
  display: grid;
  gap: 4px;
}
.live-calc .calc-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.live-calc .calc-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.15rem;
}

/* ---------- Tabela de Remessas ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table-scroll { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
table.data th,
table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  background: var(--surface-2);
  font-weight: 500;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  position: sticky;
  top: 0;
}
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tfoot td {
  background: var(--surface-2);
  font-weight: 600;
  border-top: 2px solid var(--border-2);
  border-bottom: none;
}
table.data .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.data .col-actions { width: 1%; text-align: right; }

/* Tabela de usuarios: padding compacto, emails podem quebrar */
table.data-users th,
table.data-users td {
  padding: 10px 8px;
  font-size: .88rem;
}
table.data-users td:nth-child(2) {  /* coluna email */
  white-space: normal;
  word-break: break-all;
  max-width: 220px;
  font-size: .82rem;
  line-height: 1.35;
}
table.data-users .col-actions { white-space: nowrap; }

/* Tabela de webhooks: respiro maior e quebra apenas onde precisa */
table.data-webhooks th,
table.data-webhooks td {
  padding: 12px 14px;
  vertical-align: top;
  font-size: .87rem;
}
table.data-webhooks td:nth-child(1) {  /* Recebido */
  white-space: nowrap;
  padding-top: 14px;
}
table.data-webhooks td:nth-child(2) {  /* Evento (badge) */
  white-space: nowrap;
  padding-top: 14px;
}
table.data-webhooks td:nth-child(3) {  /* Email comprador */
  white-space: normal;
  word-break: break-all;
  max-width: 200px;
  font-size: .82rem;
  line-height: 1.45;
}
table.data-webhooks td:nth-child(4) {  /* Transação */
  white-space: nowrap;
  font-size: .78rem;
  padding-top: 14px;
}
table.data-webhooks td:nth-child(5) {  /* Resultado (longo) */
  white-space: normal;
  word-break: break-word;
  max-width: 360px;
  font-size: .82rem;
  line-height: 1.5;
}
table.data-webhooks td:nth-child(6) {  /* Status */
  white-space: nowrap;
  padding-top: 14px;
}
table.data-webhooks .col-actions {
  white-space: nowrap;
  vertical-align: middle;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }
.bau  { color: var(--info); }

/* ---------- Pílulas / badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: .75rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
}
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: .72rem;
  background: rgba(251,191,36,.12);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-left: 6px;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 20% 10%, rgba(251,191,36,.07), transparent 60%),
    radial-gradient(800px 400px at 80% 90%, rgba(74,222,128,.05), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}
.login-card .subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 24px;
}

/* ---------- Empty state ---------- */
.empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { color: var(--text); margin-bottom: 8px; }
.empty .icon {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(251,191,36,.12), rgba(251,191,36,.02) 70%);
  border: 1px solid rgba(251,191,36,.18);
  position: relative;
}
.empty .icon::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px dashed rgba(251,191,36,.15);
  animation: spin-slow 30s linear infinite;
}
.empty .icon i {
  font-size: 2.4rem;
  color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(251,191,36,.4));
}
@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

/* ---------- Mini bar chart ---------- */
.spark-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
  padding: 8px 0;
}
.spark-bar {
  flex: 1;
  min-width: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  position: relative;
  transition: opacity .2s;
}
.spark-bar.pos { background: var(--pos); opacity: .85; }
.spark-bar.neg { background: var(--neg); opacity: .85; }
.spark-bar:hover { opacity: 1; }
.spark-bar .tip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  padding: 4px 8px;
  font-size: .72rem;
  border-radius: 4px;
  white-space: nowrap;
  font-family: var(--font-mono);
  margin-bottom: 4px;
  z-index: 2;
}
.spark-bar:hover .tip { display: block; }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--dim);
  font-size: .82rem;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ---------- Responsivo ---------- */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .user-area { margin-left: auto; }
  .container { padding: 20px 14px 60px; }
  h1 { font-size: 1.6rem; }
  table.data th, table.data td { padding: 10px 8px; font-size: .85rem; }
  .kpi-value { font-size: 1.4rem; }
}