:root {
  --bg: #09090b;
  --surf: #131318;
  --surf2: #1c1c24;
  --txt: #fafafa;
  --txt2: #a1a1aa;
  --txt3: #71717a;
  --brd: rgba(255,255,255,0.08);
  --brd2: rgba(255,255,255,0.14);
  --acc: #3b82f6;
  --acc2: #60a5fa;
  --grn: #22c55e;
  --red: #ef4444;
  --yel: #f59e0b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--txt); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { width: 360px; min-height: 480px; }

.app { padding: 14px 16px 18px; }

.hd { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--brd); margin-bottom: 14px; }
.hd-logo { display: flex; gap: 10px; align-items: center; }
.hd-title { font-size: 0.92rem; font-weight: 800; line-height: 1; }
.hd-sub { font-size: 0.72rem; color: var(--txt3); margin-top: 2px; }
.hd-version { font-size: 0.6rem; opacity: 0.7; margin-left: 4px; letter-spacing: 0.3px; }
.hd-status { font-size: 0.7rem; color: var(--txt3); }

/* Switch ON/OFF da extensão inteira (header do popup) */
.ext-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.ext-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.ext-toggle-slider {
  position: relative; width: 36px; height: 20px; background: #2a3349;
  border-radius: 999px; transition: background .15s ease;
}
.ext-toggle-slider::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.ext-toggle input:checked + .ext-toggle-slider { background: var(--grn); }
.ext-toggle input:checked + .ext-toggle-slider::after { transform: translateX(16px); }
.ext-toggle-label { font-size: 0.7rem; font-weight: 700; color: var(--txt3); letter-spacing: 0.5px; }
.ext-toggle input:checked ~ .ext-toggle-label { color: var(--grn); }

.ext-off-banner {
  background: rgba(244,63,94,.08); border: 1px solid rgba(244,63,94,.3);
  color: #fda4af; font-size: 0.78rem; padding: 8px 12px; border-radius: 8px;
  margin-bottom: 12px; line-height: 1.4;
}

h2 { font-size: 1rem; font-weight: 700; margin: 0 0 6px; }
.muted { color: var(--txt2); font-size: 0.78rem; line-height: 1.5; margin: 0 0 12px; }

label { display: block; font-size: 0.74rem; color: var(--txt2); margin-bottom: 4px; }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%; padding: 9px 11px; background: var(--surf2); border: 1px solid var(--brd2);
  border-radius: 8px; color: var(--txt); font-size: 0.86rem; outline: none;
  margin-bottom: 10px;
}
input:focus { border-color: var(--acc); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 0.84rem; font-weight: 600; transition: all 0.15s;
  background: var(--surf2); color: var(--txt); }
.btn:hover { background: var(--surf); }
.btn-p { background: var(--acc); color: #fff; }
.btn-p:hover { background: var(--acc2); }
.btn-w { background: var(--surf2); }
.btn-g { background: transparent; border: 1px solid var(--brd2); }
.btn-sm { padding: 6px 10px; font-size: 0.76rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
button { font-family: inherit; }

.err { color: var(--red); background: rgba(244,63,94,0.1); border: 1px solid rgba(244,63,94,0.3);
  padding: 8px 10px; border-radius: 8px; font-size: 0.78rem; margin-top: 8px; }

#form-login button { width: 100%; margin-top: 6px; }

.alt { text-align: center; margin-top: 14px; font-size: 0.78rem; }
.alt a { color: var(--acc2); text-decoration: none; }
.alt a:hover { text-decoration: underline; }

/* Home view */
.user-card { display: flex; gap: 10px; align-items: center; padding: 12px; background: var(--surf);
  border: 1px solid var(--brd); border-radius: 10px; margin-bottom: 12px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--acc);
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; }
.user-name { font-size: 0.86rem; font-weight: 700; }
.user-plan { font-size: 0.7rem; color: var(--txt3); margin-top: 1px; }
.user-card .btn { margin-left: auto; }

.quota-card { background: var(--surf); border: 1px solid var(--brd); border-radius: 10px;
  padding: 14px; margin-bottom: 12px; }
.quota-row { display: grid; grid-template-columns: 92px 1fr 60px; gap: 10px; align-items: center;
  font-size: 0.76rem; margin-bottom: 10px; }
.quota-row:last-child { margin-bottom: 0; }
.quota-label { color: var(--txt2); }
.quota-bar { height: 6px; background: var(--surf2); border-radius: 999px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--acc); width: 0%; transition: width 0.3s; }
.quota-fill.warn { background: var(--yel); }
.quota-fill.danger { background: var(--red); }
.quota-num { font-size: 0.74rem; color: var(--txt2); text-align: right; }

.upsell { margin-top: 12px; padding: 10px 12px; background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.3); border-radius: 8px; }
.upsell strong { font-size: 0.82rem; color: var(--acc2); }
.upsell p { font-size: 0.72rem; color: var(--txt2); margin: 4px 0 8px; line-height: 1.4; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.actions .btn-g { grid-column: 1 / -1; }

.footer-help { font-size: 0.72rem; }

.queue-card {
  background: var(--surf); border: 1px solid var(--brd); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px;
}
.queue-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; }
.queue-head span { background: var(--acc); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 800; }
.queue-status { font-size: 0.72rem; color: var(--txt2); margin-top: 6px; line-height: 1.45; }
.queue-counts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.q-pill { padding: 2px 7px; border-radius: 999px; font-size: 0.66rem; font-weight: 700; }
.q-queued    { background: rgba(168,176,192,.15); color: var(--txt2); }
.q-downloading { background: rgba(59,130,246,.18); color: var(--acc2); }
.q-uploading { background: rgba(34,197,94,.18); color: #86efac; }
.q-done      { background: rgba(34,197,94,.12); color: #86efac; }
.q-failed    { background: rgba(244,63,94,.18); color: #fda4af; }
.q-blocked   { background: rgba(251,191,36,.18); color: var(--yel); }

.queue-items { max-height: 130px; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.queue-items::-webkit-scrollbar { width: 4px; }
.queue-items::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }
.qi {
  display: grid; grid-template-columns: 12px 1fr auto;
  gap: 6px; align-items: center; font-size: 0.7rem; color: var(--txt2);
  padding: 2px 4px;
}
.qi-dot { width: 8px; height: 8px; border-radius: 50%; }
.qi-dot.queued { background: var(--txt3); }
.qi-dot.downloading { background: var(--acc); animation: pulse 1.2s ease-in-out infinite; }
.qi-dot.uploading { background: var(--grn); animation: pulse 1.2s ease-in-out infinite; }
.qi-dot.done { background: var(--grn); }
.qi-dot.failed { background: var(--red); }
.qi-dot.blocked { background: var(--yel); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.qi-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qi-status { font-size: 0.62rem; color: var(--txt3); text-transform: uppercase; letter-spacing: 0.05em; }

.queue-actions { display: flex; gap: 6px; margin-top: 8px; }
.queue-actions .btn { flex: 1; font-size: 0.7rem; padding: 6px; }

.setting-group {
  background: var(--surf); border: 1px solid var(--brd); border-radius: 10px;
  padding: 12px; margin-bottom: 10px;
}
.setting-head {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--txt3); margin-bottom: 10px;
}
.setting-row {
  display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: flex-start;
  padding: 8px 0; cursor: pointer;
  border-bottom: 1px solid var(--brd);
}
.setting-row:last-of-type { border-bottom: none; padding-bottom: 4px; }
.setting-row input[type="checkbox"],
.setting-row input[type="radio"] {
  width: 16px; height: 16px; margin-top: 1px; accent-color: var(--acc);
}
.setting-title { font-size: 0.82rem; font-weight: 600; color: var(--txt); }
.setting-desc { font-size: 0.72rem; color: var(--txt2); margin-top: 3px; line-height: 1.45; }
.setting-info {
  background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.25);
  padding: 8px 10px; border-radius: 8px; margin-top: 10px;
  font-size: 0.72rem; color: var(--txt2); line-height: 1.45;
}
.setting-info.warn {
  background: rgba(251,191,36,0.08); border-color: rgba(251,191,36,0.4); color: #fde68a;
}
.setting-info.ok {
  background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.35); color: #86efac;
}

.setting-select-row {
  display: grid; grid-template-columns: 60px 1fr auto auto; gap: 8px; align-items: center;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--brd);
}
.setting-select-label { font-size: 0.74rem; color: var(--txt2); }
.setting-select {
  width: 100%; padding: 6px 9px; background: var(--surf2); border: 1px solid var(--brd2);
  border-radius: 6px; color: var(--txt); font-size: 0.78rem; font-family: inherit;
}
.setting-refresh {
  background: var(--surf2); border: 1px solid var(--brd2); color: var(--txt2);
  width: 26px; height: 26px; border-radius: 6px; cursor: pointer; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center; padding: 0;
  transition: transform 0.4s, background 0.15s;
}
.setting-refresh:hover { background: var(--brd); color: var(--txt); }
.setting-refresh.spinning { animation: setting-refresh-spin 0.6s linear; }
@keyframes setting-refresh-spin { to { transform: rotate(360deg); } }
.setting-link { font-size: 0.7rem; color: var(--acc2); text-decoration: none; white-space: nowrap; }
.setting-link:hover { text-decoration: underline; }
.is-premium-tag {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.06em; margin-left: 8px;
  background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff;
  padding: 2px 6px; border-radius: 4px; vertical-align: middle;
}
.is-premium-msg {
  margin-top: 10px; padding: 8px 10px; font-size: 0.74rem;
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25);
  border-radius: 6px; color: var(--txt2);
}
.is-premium-link { color: var(--acc2); font-weight: 600; cursor: pointer; text-decoration: none; }
.is-premium-link:hover { text-decoration: underline; }
.setting-row input[type="checkbox"]:disabled + div { opacity: 0.55; }

/* ── Checkout view ───────────────────────────────────────────────── */
.checkout-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 0; color: var(--txt2); font-size: 0.84rem; }
.spinner {
  width: 32px; height: 32px; border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--acc);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
.spinner-mini { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.15); border-top-color: var(--acc); border-radius: 50%; animation: spin 0.9s linear infinite; display: inline-block; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.pix-amount { background: linear-gradient(135deg, rgba(59,130,246,.18), rgba(34,197,94,.12)); border: 1px solid rgba(59,130,246,.3); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.pix-amount-label { font-size: 0.74rem; color: var(--txt2); text-transform: uppercase; letter-spacing: 0.06em; }
.pix-amount-value { font-size: 1.5rem; font-weight: 800; color: #fff; }

.pix-qr-wrap { text-align: center; margin: 14px 0; }
.pix-qr { width: 200px; height: 200px; border: 1px solid var(--brd); border-radius: 10px; background: #fff; padding: 6px; box-sizing: border-box; }
.pix-qr-hint { font-size: 0.7rem; color: var(--txt3); margin-top: 6px; }

.pix-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--txt3); font-size: 0.7rem; }
.pix-divider::before, .pix-divider::after { content: ''; flex: 1; height: 1px; background: var(--brd); }

.pix-copypaste-wrap { margin-bottom: 12px; }
.pix-copypaste-label { font-size: 0.72rem; color: var(--txt2); margin-bottom: 6px; font-weight: 600; }
.pix-copypaste { width: 100%; height: 60px; padding: 8px; background: var(--surf2); border: 1px solid var(--brd2); border-radius: 8px; color: var(--txt); font-size: 0.7rem; font-family: ui-monospace, monospace; resize: none; line-height: 1.4; }

.checkout-status { background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.25); border-radius: 8px; padding: 10px; font-size: 0.78rem; color: var(--txt2); text-align: center; margin-top: 14px; }

.checkout-success { text-align: center; padding: 30px 14px; }
.checkout-success-icon { font-size: 3rem; line-height: 1; margin-bottom: 10px; }
.checkout-success h3 { font-size: 1.1rem; margin: 6px 0 4px; color: var(--grn); }
.checkout-success p { color: var(--txt2); margin: 6px 0 20px; font-size: 0.84rem; }

.checkout-error { padding: 14px 0; }
.checkout-error .err { margin-bottom: 12px; }
.checkout-error .btn { width: 100%; }
