:root {
  --bg: #0B0F19;
  --surface: #121826;
  --surface-2: rgba(20, 27, 45, 0.85);
  --border: rgba(0, 240, 255, 0.16);
  --border-soft: rgba(255, 255, 255, 0.08);
  --cyan: #00F0FF;
  --cyan-dim: rgba(0, 240, 255, 0.14);
  --green: #10B981;
  --green-dim: rgba(16, 185, 129, 0.16);
  --amber: #F59E0B;
  --amber-dim: rgba(245, 158, 11, 0.16);
  --red: #EF4444;
  --red-dim: rgba(239, 68, 68, 0.16);
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 0%, rgba(0, 240, 255, 0.11), transparent 45%),
              radial-gradient(circle at 90% 100%, rgba(16, 185, 129, 0.09), transparent 45%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }

.app-shell {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

.view { min-height: 100dvh; }

/* Splash */
.view-splash {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.splash-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.splash-gif {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 28px;
  border: 1px solid var(--border);
  box-shadow: 0 0 36px rgba(0, 240, 255, 0.25);
}
.splash-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.splash-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}
.splash-brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.splash-brand h1 span {
  color: var(--cyan);
}
.splash-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}
.spinner-ring {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border-soft);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth */
.view-auth {
  padding: calc(22px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.auth-header h1 {
  margin: 0;
  font-size: 20px;
}
.auth-header h1 span { color: var(--cyan); }
.auth-header p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

/* Glass Cards */
.glass-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.banner-a2hs {
  border-color: rgba(0, 240, 255, 0.35);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.12), rgba(18, 24, 38, 0.92));
}
.a2hs-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--cyan);
  margin-bottom: 4px;
}
.a2hs-desc {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text);
}

/* Segmented Tabs */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(11, 15, 25, 0.85);
  border-radius: 12px;
  padding: 4px;
  border: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 9px 10px;
  font-weight: 600;
  font-size: 13px;
  border-radius: 9px;
  cursor: pointer;
}
.seg-btn.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.22), rgba(16, 185, 129, 0.16));
  color: var(--text);
  border: 1px solid var(--border);
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field label, .ctrl-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
input, select {
  width: 100%;
  background: #0B0F19;
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--cyan);
}
.input-with-btn {
  display: flex;
  gap: 8px;
}
.btn-inline {
  border: 1px solid var(--border-soft);
  background: #0B0F19;
  color: var(--cyan);
  border-radius: 11px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.inline-form {
  display: flex;
  gap: 8px;
}
.inline-form input { flex: 1; }

/* Buttons */
button { font-family: inherit; }
.btn-primary, .btn-primary-sm, .btn-sr-launch {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #00F0FF, #10B981);
  color: #061018;
  font-weight: 800;
  font-size: 14px;
  padding: 13px 16px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.btn-primary-sm { padding: 10px 14px; font-size: 13px; }
.btn-sr-launch {
  padding: 15px 16px;
  font-size: 15px;
  box-shadow: 0 6px 24px rgba(0, 240, 255, 0.28);
}
.btn-primary:active, .btn-sr-launch:active { transform: scale(0.985); }
.btn-primary:disabled, .btn-outline:disabled { opacity: 0.55; cursor: wait; }

.btn-secondary {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--cyan-dim);
  color: var(--cyan);
  font-weight: 700;
  padding: 11px 14px;
  width: 100%;
  cursor: pointer;
}
.btn-outline {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(11, 15, 25, 0.65);
  color: var(--text);
  font-weight: 600;
  padding: 10px 12px;
  width: 100%;
  cursor: pointer;
}
.btn-outline-warn {
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 12px;
  background: var(--amber-dim);
  color: #FCD34D;
  font-weight: 700;
  padding: 11px 14px;
  width: 100%;
  cursor: pointer;
}
.btn-danger {
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 12px;
  background: var(--red-dim);
  color: #FCA5A5;
  font-weight: 700;
  padding: 11px 14px;
  width: 100%;
  cursor: pointer;
}
.btn-ghost-sm {
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-muted);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.btn-link {
  border: 0;
  background: transparent;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.device-meta-pill {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}
.device-meta-pill code {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.alert-box {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
}
.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #FECACA;
}

/* Main App Layout */
.view-main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(11, 15, 25, 0.88);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(12px);
}
.top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}
.top-title {
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.badge-ios {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid var(--border);
}
.top-sub {
  font-size: 11px;
  color: var(--text-muted);
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--cyan);
  font-size: 18px;
  cursor: pointer;
}

.main-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(86px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Hero & Quick Connect Orb */
.hero-card { padding: 12px; }
.hero-media {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  height: 92px;
  margin-bottom: 12px;
}
.hero-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.75);
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(11, 15, 25, 0.9), transparent);
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}
.status-ready {
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid var(--border);
}
.status-bound {
  background: var(--green-dim);
  color: #6EE7B7;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.pill-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #0B0F19;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}
.pill-toggle.compact { flex: 1; }
.pill-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.pill-btn.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid var(--border);
}
.port-selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.port-selector-row .ctrl-label { margin: 0; white-space: nowrap; }

.orb-wrap {
  display: flex;
  justify-content: center;
  margin: 6px 0 14px;
}
.connect-orb {
  position: relative;
  width: 196px;
  height: 196px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: radial-gradient(circle at 30% 25%, rgba(0, 240, 255, 0.24), rgba(11, 15, 25, 0.96) 72%);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 34px rgba(0, 240, 255, 0.22), inset 0 0 22px rgba(0, 240, 255, 0.14);
}
.orb-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(0, 240, 255, 0.35);
  animation: pulseOrb 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes pulseOrb {
  0% { transform: scale(0.96); opacity: 0.75; }
  70% { transform: scale(1.06); opacity: 0; }
  100% { transform: scale(1.06); opacity: 0; }
}
.orb-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
}
.orb-core strong {
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--cyan);
}
.orb-core small {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 140px;
}
.quick-actions-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Card Elements */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.card-head h2 {
  margin: 0;
  font-size: 15px;
}
.card-note {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
}
.card-actions { margin-top: 10px; }

.chip {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}
.chip-cyan { background: var(--cyan-dim); color: var(--cyan); }
.chip-green { background: var(--green-dim); color: #6EE7B7; }
.chip-amber { background: var(--amber-dim); color: #FCD34D; }
.chip-red { background: var(--red-dim); color: #FCA5A5; }
.chip-muted { background: rgba(148, 163, 184, 0.16); color: var(--text-muted); }

.mono-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 8px;
  background: #0B0F19;
  border: 1px solid var(--border-soft);
  color: var(--cyan);
}

.kv-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding-bottom: 5px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}
.kv-row:last-child { border-bottom: 0; padding-bottom: 0; }
.kv-row span:first-child { color: var(--text-muted); }
.kv-row span:last-child {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.sub-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.metric-label { font-size: 11px; color: var(--text-muted); }
.metric-value { font-size: 14px; font-weight: 700; }

.quota-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #0B0F19;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transition: width 0.3s ease;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ip-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #0B0F19;
  border: 1px solid var(--border);
  color: #6EE7B7;
}

/* Search & Hunt */
.combo-box {
  background: rgba(11, 15, 25, 0.72);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px;
}
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 8px;
}
.check-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.check-grid input { width: auto; }
.range-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.target-card {
  margin-top: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 240, 255, 0.07);
  border: 1px solid var(--border);
}
.results-stack {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.candidate-card {
  background: #0B0F19;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cand-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.cand-ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
}
.octet-match { color: #10B981; }
.octet-rest { color: var(--text); }
.cand-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.catalog-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.country-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #0B0F19;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 11px 12px;
}
.country-card strong { display: block; font-size: 14px; }
.country-card small { color: var(--text-muted); font-size: 11px; }
.country-card button { width: auto; padding: 8px 12px; }

/* Account Guide & Stack */
.guide-steps {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.guide-steps strong { color: var(--text); }
.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(11, 15, 25, 0.94);
  border-top: 1px solid var(--border-soft);
  backdrop-filter: blur(16px);
  padding: 6px 8px calc(8px + var(--safe-bottom));
  z-index: 20;
}
.nav-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.nav-ico { font-size: 17px; line-height: 1.1; }
.nav-btn.active { color: var(--cyan); }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 12px;
}
.modal-sheet {
  width: 100%;
  max-width: 500px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #121826;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.close-btn {
  border: 1px solid var(--border-soft);
  background: #0B0F19;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.sr-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.sr-quick-copy {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.qr-toggle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.qr-box {
  width: 210px;
  height: 210px;
  padding: 8px;
  border-radius: 14px;
  background: #FFFFFF;
}
.qr-box svg { width: 100%; height: 100%; display: block; }

.sr-fields-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0B0F19;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px;
}
.sr-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.sr-field-row code {
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 210px;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  top: calc(16px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: 440px;
  width: calc(100% - 32px);
  background: #0F172A;
  border: 1px solid var(--cyan);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  z-index: 80;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
