:root {
  --bg: #0f1220;
  --bg-soft: #171a2b;
  --card: #1d2136;
  --card-2: #232842;
  --border: #2c3252;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --brand: #4f7cff;
  --brand-2: #6c8bff;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #1c2140 0, transparent 60%), var(--bg);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100%;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 32, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}
.brand .logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-size: 16px;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s ease, border 0.15s ease;
}
.btn:hover { background: #2a3050; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.btn-danger { background: transparent; border-color: #4a2733; color: #ff9aa6; }
.btn-danger:hover { background: #3a1f28; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.section-title {
  font-size: 1.15rem;
  margin: 26px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.86rem; color: var(--muted); }
.input, .textarea, select.input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.input:focus, .textarea:focus, select.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.2);
}
.textarea { min-height: 78px; resize: vertical; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.auth-card { width: 100%; max-width: 400px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--bg-soft); padding: 4px; border-radius: 12px; }
.tab {
  flex: 1; text-align: center; padding: 9px; border-radius: 9px;
  cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--muted);
}
.tab.active { background: var(--card-2); color: var(--text); }

/* ---------- Candidate / frame cards ---------- */
.cand-card { display: flex; flex-direction: column; gap: 10px; }
.cand-card h3 { margin: 0; font-size: 1.05rem; }
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; background: var(--card-2); color: var(--muted);
  border: 1px solid var(--border);
}
.frame-thumb {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 10px;
  background: repeating-conic-gradient(#2a2f4d 0% 25%, #232842 0% 50%) 50% / 20px 20px;
  display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border);
}
.frame-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Link box ---------- */
.linkbox {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 8px 8px 12px;
}
.linkbox input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 0.85rem; }
.linkbox input:focus { outline: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100;
  font-size: 0.9rem;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
#toast.error { border-color: var(--red); }
#toast.ok { border-color: var(--green); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 5, 15, 0.7);
  display: none; place-items: center; z-index: 60; padding: 18px;
}
.modal-backdrop.show { display: grid; }
.modal { width: 100%; max-width: 460px; }

/* ---------- Editor (pagina publica) ---------- */
.editor-stage {
  position: relative; width: 100%; max-width: 460px; margin: 0 auto;
  background: repeating-conic-gradient(#e9ecf5 0% 25%, #f7f9ff 0% 50%) 50% / 22px 22px;
  border-radius: 14px; overflow: hidden; touch-action: none;
  border: 1px solid var(--border);
}
.editor-stage canvas { display: block; width: 100%; height: auto; cursor: grab; }
.editor-stage canvas:active { cursor: grabbing; }

.zoom-row { display: flex; align-items: center; gap: 12px; margin: 16px 0 6px; }
.zoom-row input[type=range] { flex: 1; }
input[type=range] { accent-color: var(--brand); }

.format-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--muted);
}
.pill.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }

.hidden { display: none !important; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* Upload drop zone */
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 26px 16px;
  text-align: center; cursor: pointer; background: var(--bg-soft); transition: border 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--brand); background: #191d30; }
.dropzone strong { color: var(--brand-2); }

/* ---------- Plano / Admin ---------- */
.plan-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; font-size: 0.76rem; font-weight: 800;
  border: 1px solid var(--border); background: var(--card-2); color: var(--muted);
}
.plan-pill.pro { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }
.plan-pill.admin { border-color: #6b4bb8; color: #d6c5ff; background: #241c3a; }

.price-tag { margin-bottom: 14px; }
.price-tag .big { font-size: 2rem; font-weight: 800; display: block; }
.pro-list { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; display: grid; gap: 8px; }
.pro-list li { font-size: 0.92rem; color: var(--text); }

/* Cabeçalho da área admin */
.admin-head { margin: 4px 0 20px; }
.admin-head h2 { margin: 0 0 4px; font-size: 1.35rem; }
.admin-head p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* Cards de métrica */
.stats-row {
  display: grid; gap: 12px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 15px 16px; display: flex; align-items: center; gap: 12px;
}
.stat-card .stat-ic {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 11px; display: grid; place-items: center;
  font-size: 1.1rem; background: var(--card-2); border: 1px solid var(--border);
}
.stat-card .sv { font-size: 1.4rem; font-weight: 800; line-height: 1.1; }
.stat-card .sl { color: var(--muted); font-size: 0.78rem; }
.stat-card.accent { border-color: rgba(79,124,255,.5); background: linear-gradient(135deg, rgba(79,124,255,.14), transparent); }
.stat-card.accent .stat-ic { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; }
.stat-card.money .sv { color: var(--green); }
.stat-card.money .stat-ic { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.4); }

/* Barra de busca */
.admin-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.search-box {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 11px;
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,124,255,.18); }
.search-box .ic { color: var(--muted); flex: 0 0 auto; }
.search-box input { flex: 1; min-width: 0; background: transparent; border: none; color: var(--text); padding: 12px 0; font-size: 0.92rem; }
.search-box input:focus { outline: none; }

/* Tabela de usuários */
.table-wrap { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--card); }
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 760px; }
.admin-table thead th {
  position: sticky; top: 0; background: var(--bg-soft); color: var(--muted);
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
  text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.admin-table .col-c { text-align: center; }

.user-cell { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.avatar {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 0.9rem; color: #fff; letter-spacing: -0.02em;
}
.u-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.u-email { color: var(--muted); font-size: 0.8rem; }
.count-pill {
  display: inline-block; min-width: 30px; text-align: center; padding: 3px 10px; border-radius: 8px;
  background: var(--card-2); border: 1px solid var(--border); font-weight: 700; font-size: 0.85rem;
}
.count-pill.zero { color: var(--muted); font-weight: 600; }
.exp-note { color: var(--muted); font-size: 0.74rem; margin-top: 3px; }

.actions { display: flex; gap: 6px; align-items: center; }
.actions .sep { flex: 1; min-width: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  font-size: 0.8rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: filter .15s, background .15s, border .15s;
}
.icon-btn:hover { filter: brightness(1.12); }
.icon-btn.go { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; }
.icon-btn.warn { background: transparent; }
.icon-btn.danger { background: transparent; border-color: #4a2733; color: #ff9aa6; }
.icon-btn.danger:hover { background: #3a1f28; filter: none; }

.tag-role { font-size: 0.62rem; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: #241c3a; color: #d6c5ff; border: 1px solid #6b4bb8; letter-spacing: 0.03em; }

.admin-empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Configuração de pagamento */
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 0.92rem; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--brand); }

/* Checkout embutido */
.checkout-grid { display: grid; grid-template-columns: 1fr; gap: 18px; max-width: 560px; }
.pix-qr { width: 220px; max-width: 70%; height: auto; border-radius: 12px; background: #fff; padding: 8px; }
.pix-status { margin-top: 14px; font-weight: 700; font-size: 0.92rem; color: var(--muted); }
.pix-status.ok { color: var(--green); }
#brickContainer { min-height: 4px; }

/* No celular, a tabela vira cards empilhados (sem rolagem lateral) */
@media (max-width: 720px) {
  .table-wrap { border: none; background: transparent; border-radius: 0; }
  .table-scroll { overflow: visible; }
  .admin-table { min-width: 0; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr {
    background: var(--card); border: 1px solid var(--border); border-radius: 14px;
    margin-bottom: 12px; padding: 6px 2px; overflow: hidden;
  }
  .admin-table tbody tr:hover { background: var(--card); }
  .admin-table td {
    border-bottom: 1px solid var(--border); padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right;
  }
  .admin-table td:last-child { border-bottom: none; }
  .admin-table td::before {
    content: attr(data-label); color: var(--muted); font-size: 0.7rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.04em; text-align: left; flex: 0 0 auto;
  }
  .admin-table td.user-td { justify-content: flex-start; text-align: left; background: var(--bg-soft); }
  .admin-table td.user-td::before { display: none; }
  .admin-table .col-c { text-align: right; }
  .admin-table td.acts-td { flex-direction: column; align-items: stretch; gap: 8px; }
  .admin-table td.acts-td::before { margin-bottom: 2px; }
  .admin-table .actions { flex-wrap: wrap; gap: 8px; }
  .admin-table .actions .icon-btn { flex: 1; justify-content: center; min-width: 92px; }
  .admin-table .actions .sep { display: none; }
}

@media (max-width: 560px) {
  .container { padding: 16px 12px 50px; }
  .card { padding: 16px; }
}
