/* =====================================================
   VYBLER — painel (dashboard + editor) — AUTOSSUFICIENTE
   (não depende do base.css; evita conflitos de .field/.card/etc.)
   ===================================================== */
:root {
  --bg:#0d0c12; --bg-2:#09080d; --bg-3:#15131c;
  --surface:#17151f; --surface-2:#201d2b;
  --border:rgba(243,242,247,.10); --border-strong:rgba(243,242,247,.18);
  --text:#f3f2f7; --text-muted:#a8a6b4; --text-faint:#6e6c7d;
  --brand:#8b5cf6; --brand-soft:#a78bfa; --on-brand:#fff;
  --radius:16px; --radius-lg:22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: 'Space Grotesk', Inter, sans-serif; letter-spacing: -.01em; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:.5rem; padding:.7rem 1.2rem; border-radius:999px; border:1px solid transparent; font:inherit; font-weight:600; font-size:.85rem; cursor:pointer; transition:transform .15s, background .2s, border-color .2s; white-space:nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-soft); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { border-color: var(--text); }
.btn.sm { padding:.45rem .8rem; font-size:.76rem; }
.logo { display:inline-flex; align-items:center; gap:.5rem; font-family:'Space Grotesk',sans-serif; font-weight:700; }
.logo-mark { width:30px; height:30px; }
.logo-mark path { fill: var(--brand); }
.logo-text { font-size:1.05rem; letter-spacing:.14em; }

#app { min-height: 100vh; }
.loading { display: grid; place-items: center; min-height: 100vh; color: var(--text-muted); }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem clamp(1rem, 4vw, 2rem);
  background: rgba(13,12,18,.8); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .logo { gap: .5rem; }
.topbar .who { display: flex; align-items: center; gap: 1rem; color: var(--text-muted); font-size: .85rem; }

.page { width: min(1080px, 94%); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) 0 4rem; }

/* ---------- AUTH ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.2rem;
}
.auth-card .logo { justify-content: center; margin-bottom: 1.4rem; }
.auth-card h1 { font-size: 1.4rem; text-align: center; margin: 0 0 .3rem; }
.auth-card .sub { text-align: center; color: var(--text-muted); font-size: .9rem; margin: 0 0 1.6rem; }
.auth-tabs { display: flex; gap: .3rem; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; padding: .25rem; margin-bottom: 1.4rem; }
.auth-tabs button { flex: 1; border: none; background: transparent; color: var(--text-muted); padding: .55rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .82rem; }
.auth-tabs button.active { background: var(--brand); color: var(--on-brand); }

/* ---------- form fields ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: .4rem; }
.input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px;
  padding: .75rem .85rem; color: var(--text); font: inherit; font-size: .95rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(139,92,246,.18); }
.input.bad { border-color: #e0556e; }
.row { display: flex; gap: .8rem; }
.row > * { flex: 1; }
.hint { font-size: .76rem; margin-top: .35rem; }
.hint.ok { color: #4ade80; } .hint.err { color: #e0556e; }
.hint.locked { color: var(--text-faint); }
.slug-row { display: flex; align-items: center; gap: .5rem; }
.slug-row .slug-prefix { color: var(--text-faint); white-space: nowrap; font-size: .92rem; }
.slug-row .input { flex: 1; min-width: 0; }
.slug-row.is-locked .input { opacity: .55; cursor: not-allowed; background: var(--bg-2); }
.err-box { background: rgba(224,85,110,.12); border: 1px solid rgba(224,85,110,.4); color: #f1a8b4; padding: .7rem .85rem; border-radius: 10px; font-size: .85rem; margin-bottom: 1rem; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; color: var(--text); font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ---------- dashboard list ---------- */
.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.6rem; flex-wrap: wrap; gap: 1rem; }
.dash-head h1 { font-size: 1.6rem; margin: 0; }
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1.1rem; }
.link-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; min-width: 0; }
.link-card .slug { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.1rem; word-break: break-all; }
.link-card .slug span { color: var(--text-faint); }
.tagmode { display: inline-block; font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: .2rem .55rem; border-radius: 999px; margin: .5rem 0; }
.tagmode--page { background: rgba(139,92,246,.16); color: var(--brand-soft); }
.tagmode--redirect { background: rgba(255,255,255,.08); color: var(--text-muted); }
.link-card .acts { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.link-card .acts .btn { flex: 0 0 auto; }
.empty { text-align: center; color: var(--text-muted); padding: 3rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- Filtro por criador/categoria (painel) ---------- */
.cat-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem 1.2rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.cat-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.cat-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .42rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text-muted); font: inherit; font-weight: 600; font-size: .8rem; cursor: pointer; transition: border-color .2s, color .2s, background .2s; }
.cat-chip:hover { color: var(--text); border-color: var(--border-strong); }
.cat-chip.active { color: var(--text); border-color: var(--cc, var(--brand)); background: var(--cc-bg, rgba(139,92,246,.14)); }
.cat-chip .cat-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--cc, var(--text-faint)); flex: none; }
.cat-chip .cat-count { font-size: .72rem; font-weight: 700; color: var(--text-faint); }
.cat-chip.active .cat-count { color: var(--text-muted); }
.cat-search { max-width: 260px; width: 100%; }

/* badge do criador no card */
.link-cat { display: inline-flex; align-items: center; gap: .4rem; max-width: 100%; padding: .24rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; color: var(--cc, var(--text-muted)); background: var(--cc-bg, rgba(255,255,255,.06)); margin-bottom: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-cat .cat-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--cc, var(--text-faint)); flex: none; }
.link-cat.is-none { color: var(--text-faint); background: rgba(255,255,255,.05); }

/* cabeçalho de grupo (visão agrupada) */
.cat-group { margin-bottom: 1.9rem; }
.cat-group-head { display: flex; align-items: center; gap: .6rem; margin: 0 0 1rem; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.cat-group-head .cat-dot { width: 11px; height: 11px; border-radius: 999px; background: var(--cc, var(--text-faint)); flex: none; }
.cat-group-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.cat-group-count { font-size: .76rem; font-weight: 700; color: var(--text-faint); background: var(--bg-2); border: 1px solid var(--border); padding: .1rem .5rem; border-radius: 999px; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 1fr 360px; gap: 2rem; align-items: start; }
.editor-form { min-width: 0; }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; padding: .25rem; margin-bottom: 1.4rem; }
.seg button { border: none; background: transparent; color: var(--text-muted); padding: .55rem 1.1rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .82rem; }
.seg button.active { background: var(--brand); color: var(--on-brand); }

.cards-edit { display: flex; flex-direction: column; gap: .7rem; }
.card-row { display: grid; grid-template-columns: 56px 1fr auto; gap: .7rem; align-items: center; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: .7rem; }
.card-thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--bg-3) center/cover; border: 1px solid var(--border); cursor: pointer; display: grid; place-items: center; color: var(--text-faint); font-size: .65rem; text-align: center; overflow: hidden; }
.card-fields { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.card-fields .input { padding: .5rem .65rem; font-size: .85rem; }
.card-mini { display: flex; gap: .4rem; align-items: center; }
.card-mini select { background: var(--bg-3); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: .35rem; font-size: .8rem; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-3); color: var(--text-muted); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { color: var(--text); border-color: var(--text-muted); }
.card-acts { display: flex; flex-direction: column; gap: .3rem; }

.cover-pick { display: flex; align-items: center; gap: 1rem; }
.cover-thumb { width: 72px; height: 72px; border-radius: 12px; background: var(--bg-3) center/cover; border: 1px solid var(--border); }

/* preview phone */
.preview-col { position: sticky; top: 90px; }
.phone {
  width: 300px; max-width: 100%; margin: 0 auto;
  aspect-ratio: 320/640; background: #000;
  border: 8px solid #1c1b22; border-radius: 34px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.phone iframe { width: 100%; height: 100%; border: 0; display: block; background: #0a0a0d; }
.preview-cap { text-align: center; color: var(--text-faint); font-size: .76rem; margin-top: .8rem; }
.redirect-preview { display: grid; place-items: center; height: 100%; padding: 2rem; text-align: center; color: #fff; background: #0a0a0d; }

.editor-actions { display: flex; gap: .8rem; margin-top: 1.6rem; flex-wrap: wrap; }

@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; }
  .preview-col { position: static; order: -1; }
}

/* ---------- analytics ---------- */
.period-tabs { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; padding: .25rem; gap: .25rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.period-tabs button { border: none; background: transparent; color: var(--text-muted); padding: .5rem 1rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .8rem; }
.period-tabs button.active { background: var(--brand); color: var(--on-brand); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.metrics.metrics-1 { grid-template-columns: minmax(160px, 240px); }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.3rem; }
.metric .v { font-family: 'Space Grotesk', sans-serif; font-size: 1.9rem; font-weight: 700; color: var(--brand); line-height: 1; }
.metric .l { color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; margin-top: .4rem; }
.ctr-list { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1.8rem; }
.ctr-row { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; }
.ctr-row .top { display: flex; justify-content: space-between; gap: 1rem; font-size: .92rem; margin-bottom: .5rem; }
.ctr-row .top b { color: var(--text); } .ctr-row .top .pct { color: var(--brand); font-weight: 700; white-space: nowrap; font-size: 1rem; }
.ctr-row .sub { color: var(--text-faint); font-size: .8rem; margin-top: .5rem; }
.bar { height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.ctr-row.drop .bar > span { background: var(--text-faint); }
.an-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 480px); gap: 1.8rem; align-items: start; }
.an-left { min-width: 0; }
.an-h3 { margin: .4rem 0 .8rem; font-size: 1rem; }
.an-right { position: sticky; top: 1.5rem; }
.map-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1rem 1.1rem; }
.map-head { font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .7rem; }
.country-rank { display: flex; flex-direction: column; }
.c-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .3rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
.c-row .rk { flex: none; width: 1.6rem; text-align: center; font-size: 1rem; font-weight: 700; color: var(--text-faint); }
.c-row .flag { font-size: 1.1rem; flex: none; }
.c-row .c-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.c-row .c-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.c-row .nm { color: var(--text); }
.c-row .pct { color: var(--brand); font-weight: 700; font-size: 1rem; white-space: nowrap; }
.c-row .c-sub { color: var(--text-faint); font-size: .8rem; }
.map-wrap { height: 440px; }
.an-empty { color: var(--text-muted); text-align: center; padding: 2rem; border: 1px dashed var(--border); border-radius: var(--radius); }
@media (max-width: 860px) { .an-grid { grid-template-columns: 1fr; } .an-right { position: static; } .map-wrap { height: 340px; } }

/* =====================================================
   Plano (badge na topbar) + Billing + Toast
   ===================================================== */
.who { display: flex; align-items: center; gap: .6rem; }
.who-email { color: var(--text-muted); font-size: .9rem; }
.plan-badge {
  border: 1px solid var(--border-strong); background: var(--bg-2);
  color: var(--text-muted); font-size: .68rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase;
  padding: .32rem .7rem; border-radius: 999px; cursor: pointer;
  font-family: 'Space Grotesk', sans-serif; transition: filter .2s;
}
.plan-badge:hover { filter: brightness(1.2); }
.plan-badge.plan-free      { color: var(--text-muted); }
.plan-badge.plan-beginner  { color: #67e8f9; border-color: rgba(103,232,249,.4); background: rgba(103,232,249,.10); }
.plan-badge.plan-advanced  { color: var(--brand-soft); border-color: rgba(139,92,246,.5); background: rgba(139,92,246,.14); }
.plan-badge.plan-agency    { color: #fbbf24; border-color: rgba(251,191,36,.45); background: rgba(251,191,36,.12); }

.bill-note { background: rgba(139,92,246,.12); border: 1px solid rgba(139,92,246,.4); color: var(--brand-soft); padding: .75rem .95rem; border-radius: 10px; font-size: .88rem; margin-bottom: 1.3rem; }
.bill-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.6rem; color: var(--text-muted); font-size: .95rem; }
.bill-status .plan-badge { cursor: default; }

.bill-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; align-items: stretch; }
.bill-grid .tier { position: relative; display: flex; flex-direction: column; padding: 1.7rem 1.3rem; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(180deg, rgba(255,255,255,.02), transparent); }
.bill-grid .tier--pop { border-color: var(--brand); box-shadow: 0 16px 50px -12px rgba(139,92,246,.35); }
.bill-grid .tier.is-current { border-color: var(--border-strong); }
.tier-badge { position: absolute; top: -11px; right: 1.2rem; background: var(--brand); color: var(--on-brand); font-size: .8rem; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; }
.tier-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text); }
.tier-price { display: flex; align-items: flex-start; gap: .12rem; margin: .9rem 0 .15rem; color: var(--text); font-family: 'Space Grotesk', sans-serif; line-height: 1; }
.tier-price .cur { font-size: 1.1rem; font-weight: 600; margin-top: .35rem; color: var(--text-muted); }
.tier-price .amt { font-size: 2.4rem; font-weight: 700; }
.tier-price .per { font-size: .76rem; color: var(--text-muted); align-self: flex-end; margin: 0 0 .45rem .25rem; }
.tier-sub { color: var(--text-muted); font-size: .8rem; margin: -.05rem 0 .25rem; }
.tier-links { color: var(--brand-soft); font-weight: 600; font-size: .88rem; margin-bottom: 1rem; }
.tier-feats { list-style: none; padding: 0; margin: 0 0 1.2rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.tier-feats li { position: relative; padding-left: 1.35rem; color: var(--text-muted); font-size: .85rem; line-height: 1.35; }
.tier-feats li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--brand); font-weight: 700; }
.agency-total { font-size: .84rem; color: var(--text-muted); margin-bottom: .75rem; }
.agency-total b { color: var(--brand-soft); font-size: 1.02rem; }
.tier-current { color: var(--text-muted); font-weight: 700; font-size: .82rem; text-align: center; padding: .6rem; border: 1px dashed var(--border-strong); border-radius: 10px; }
.agency-pick { display: flex; align-items: center; gap: .4rem; margin-bottom: .6rem; font-size: .82rem; color: var(--text-muted); }
.agency-pick .input { width: 78px; padding: .45rem .5rem; }
.btn.block { display: flex; width: 100%; }
@media (max-width: 820px) { .bill-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .bill-grid { grid-template-columns: 1fr; } .who-email { display: none; } }

.vy-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 18px); opacity: 0; background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 12px; padding: .8rem 1.2rem; font-size: .9rem; font-weight: 500; box-shadow: 0 14px 40px rgba(0,0,0,.45); z-index: 9999; transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center; }
.vy-toast.show { opacity: 1; transform: translate(-50%, 0); }
