:root {
  --bg: #08101a;
  --surface: #121d2b;
  --surface-2: #182739;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #14b8a6;
  --accent-hover: #0d9488;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px circle at 15% 10%, rgba(14, 124, 134, 0.18), transparent 60%),
    radial-gradient(500px circle at 85% 20%, rgba(20, 184, 166, 0.12), transparent 55%);
  z-index: -1;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

.center-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(8, 16, 26, 0.78);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1,
.brand strong {
  display: block;
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #14b8a6, #0e7c86);
  color: #062124;
  font-weight: 800;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.main-grid {
  padding-top: 28px;
  padding-bottom: 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.full-span {
  grid-column: 1 / -1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  background: linear-gradient(160deg, rgba(14, 124, 134, 0.14), var(--surface) 58%);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h2, h3 {
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
}

.domain-display {
  margin-top: 6px;
  font-size: 1.35rem;
  word-break: break-all;
  color: #ffffff;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.small {
  font-size: 0.85rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(20, 184, 166, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
}

.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(8, 16, 26, 0.45);
  border: 1px solid var(--border);
}

.meta-val {
  font-weight: 600;
  font-size: 0.92rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}

.field input, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1420;
  color: var(--text);
  font-size: 0.96rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.optional-creds {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(8, 16, 26, 0.35);
}

.optional-creds summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  user-select: none;
}

.creds-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #052023;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #ffffff;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.82rem;
}

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-soft);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.alert-ok {
  background: var(--ok-soft);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

.test-box {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.86rem;
  border: 1px solid var(--border);
  background: rgba(8, 16, 26, 0.5);
}

.test-box.ok {
  border-color: rgba(34, 197, 94, 0.35);
  background: var(--ok-soft);
  color: #bbf7d0;
}

.test-box.warn {
  border-color: rgba(245, 158, 11, 0.35);
  background: var(--warn-soft);
  color: #fde68a;
}

.test-box.err {
  border-color: rgba(239, 68, 68, 0.35);
  background: var(--danger-soft);
  color: #fecaca;
}

.history-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(8, 16, 26, 0.45);
  border: 1px solid var(--border);
}

.history-item.active {
  border-color: rgba(20, 184, 166, 0.45);
  background: rgba(20, 184, 166, 0.07);
}

.history-info {
  min-width: 0;
}

.history-url {
  font-weight: 700;
  word-break: break-all;
}

.history-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.devices-head {
  align-items: center;
  flex-wrap: wrap;
}

.devices-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1420;
  color: var(--text);
  font-size: 0.86rem;
  min-width: 240px;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.devices-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(8, 16, 26, 0.45);
  border: 1px solid var(--border);
}

.device-row.online {
  border-color: rgba(34, 197, 94, 0.35);
}

.device-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.device-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #475569;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}

.device-name {
  font-weight: 700;
  color: #ffffff;
}

.tag {
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}

.tag-account {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(20, 184, 166, 0.35);
}

.tag-ok {
  background: var(--ok-soft);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

.tag-warn {
  background: var(--warn-soft);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.35);
}

.device-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

@media (max-width: 820px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .creds-grid {
    grid-template-columns: 1fr;
  }
  .history-item,
  .device-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .search-input {
    min-width: 0;
    width: 100%;
  }
}

#apk-progress { width: 100%; }
#apk-current p { overflow-wrap: anywhere; }
#apk-current a { color: var(--accent); }

/* Separadores de navegação do painel */
.tabs-bar {
  border-bottom: 1px solid var(--border);
  background: rgba(8, 16, 26, 0.55);
}

.tabs-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-top: 10px;
  padding-bottom: 10px;
}

.tab-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(20, 184, 166, 0.35);
}

.tab-count {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.tab-btn.active .tab-count {
  background: rgba(20, 184, 166, 0.28);
  color: #99f6e4;
}

.btn-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: var(--danger-soft);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
}

/* Vista de Contas agrupadas */
.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.account-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  padding: 16px;
}

.account-card.online {
  border-color: rgba(34, 197, 94, 0.28);
}

.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.account-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.account-name {
  font-size: 1.02rem;
  font-weight: 700;
}

.account-meta {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 4px;
}

.account-devices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.account-device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(8, 16, 26, 0.45);
  flex-wrap: wrap;
}
