:root {
  --bg-deep: #050814;
  --bg-card: rgba(12, 18, 36, 0.72);
  --cyan: #00f0ff;
  --violet: #a855f7;
  --pink: #ec4899;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-glass: rgba(148, 163, 184, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Cairo', system-ui, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Ambient Animated Background */
.ambient-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(95px);
  opacity: 0.35;
  animation: drift 14s ease-in-out infinite alternate;
}

.orb-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--cyan), transparent 70%);
  top: -120px;
  right: -80px;
}

.orb-2 {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, var(--pink), transparent 70%);
  bottom: -140px;
  left: -100px;
  animation-delay: -6s;
}

.grid-mesh {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 35%, black 25%, transparent 80%);
}

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-35px, 28px) scale(1.12); }
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
  background: rgba(5, 8, 20, 0.72);
  border-bottom: 1px solid var(--border-glass);
}

.top-bar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mini-core {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan), 0 0 24px var(--violet);
  animation: pulseCore 2s infinite;
}

.mini-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: var(--text-main);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.auth-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-glass {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  padding: 0.48rem 0.9rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.2s, background 0.2s;
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.45);
}

.btn-neon-login,
.btn-neon-sm {
  position: relative;
  padding: 0.5rem 1.15rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 240, 255, 0.55);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.16), rgba(168, 85, 247, 0.22));
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.22);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-neon-login:hover,
.btn-neon-sm:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 26px rgba(0, 240, 255, 0.45);
}

/* Notification Bell */
.notif-wrapper {
  position: relative;
}

.notif-badge {
  background: var(--pink);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  box-shadow: 0 0 10px var(--pink);
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 310px;
  max-width: 90vw;
  background: #0b1124;
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  z-index: 60;
}

.notif-header {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
}

.btn-enable-push {
  background: rgba(0, 240, 255, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 8px;
  padding: 0.22rem 0.55rem;
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.notif-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 0.5rem;
}

.notif-item {
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
}

.notif-item time {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 0.2rem;
}

.notif-empty {
  text-align: center;
  padding: 1.4rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Main Portal Layout */
.portal-main {
  position: relative;
  z-index: 10;
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.hero-stage {
  text-align: center;
  padding: 1rem 0 2.5rem;
}

.logic-visual {
  max-width: 540px;
  margin: 0 auto 0.5rem;
}

.gateway-svg {
  width: 100%;
  height: auto;
  display: block;
}

.flow-line {
  fill: none;
  stroke: url(#flowGrad);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  animation: dashFlow 20s linear infinite;
}

@keyframes dashFlow {
  to { stroke-dashoffset: -240; }
}

.orbit-outer {
  fill: none;
  stroke: rgba(0, 240, 255, 0.45);
  stroke-width: 2;
  stroke-dasharray: 12 8;
  transform-origin: center;
  animation: spinSlow 18s linear infinite;
}

.orbit-inner {
  fill: none;
  stroke: rgba(236, 72, 153, 0.55);
  stroke-width: 2;
  stroke-dasharray: 8 6;
  transform-origin: center;
  animation: spinReverse 12s linear infinite;
}

.hub-core {
  fill: var(--cyan);
  animation: pulseCore 2.2s ease-in-out infinite;
}

.node-ring {
  fill: rgba(12, 18, 36, 0.9);
  stroke: rgba(168, 85, 247, 0.7);
  stroke-width: 2;
}

.node-dot {
  fill: var(--pink);
}

@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

@keyframes spinReverse {
  to { transform: rotate(-360deg); }
}

@keyframes pulseCore {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.16); opacity: 1; }
}

/* Animated Neon Brand Title */
.neon-brand {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  font-weight: 900;
  letter-spacing: 3px;
  direction: ltr;
  display: inline-block;
  background: linear-gradient(90deg, #00f0ff, #a855f7, #ec4899, #00f0ff);
  background-size: 250% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: neonSweep 5s linear infinite, neonBreathe 2.8s ease-in-out infinite;
  margin-bottom: 0.65rem;
}

@keyframes neonSweep {
  0% { background-position: 0% center; }
  100% { background-position: 250% center; }
}

@keyframes neonBreathe {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.55)) drop-shadow(0 0 26px rgba(168, 85, 247, 0.45));
  }
  50% {
    filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.9)) drop-shadow(0 0 42px rgba(236, 72, 153, 0.7));
  }
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 600;
}

/* Published Links Bento Grid */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.25rem;
}

@keyframes bentoCardEnter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Double-Bezel Bento Card Shell */
.link-tile {
  position: relative;
  display: block;
  padding: 6px;
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.11);
  text-decoration: none;
  color: var(--text-main);
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(2, 6, 23, 0.45);
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1),
              border-color 0.4s cubic-bezier(0.32, 0.72, 0, 1),
              box-shadow 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  animation: bentoCardEnter 0.65s cubic-bezier(0.32, 0.72, 0, 1) backwards;
}

.link-tile:hover {
  transform: translateY(-6px);
  border-color: rgba(0, 240, 255, 0.42);
  box-shadow: 0 22px 48px rgba(0, 240, 255, 0.14), 0 10px 28px rgba(2, 6, 23, 0.55);
}

.link-tile:active {
  transform: scale(0.98);
}

.link-tile.is-offline {
  border-color: rgba(248, 113, 113, 0.3);
}

/* Inner Concentric Bento Core */
.tile-core {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.15rem;
  height: 100%;
  padding: 1.35rem 1.25rem 1.15rem;
  border-radius: 20px;
  background: linear-gradient(170deg, rgba(15, 23, 42, 0.92) 0%, rgba(8, 13, 28, 0.96) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

.tile-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Machined Logo Frame */
.tile-logo-wrap {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 18px;
  padding: 6px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
}

.link-tile:hover .tile-logo-wrap {
  transform: scale(1.06) translateY(-2px);
}

.tile-logo-wrap svg,
.tile-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.tile-launch-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(226, 232, 240, 0.8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1),
              background 0.3s ease,
              color 0.3s ease,
              border-color 0.3s ease;
}

.link-tile:hover .tile-launch-btn {
  transform: translate(-2px, -2px) scale(1.08);
  background: rgba(0, 240, 255, 0.14);
  border-color: rgba(0, 240, 255, 0.4);
  color: #00f0ff;
}

.tile-name {
  color: #f8fafc;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.45;
  text-align: right;
  margin: 0;
}

.tile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.tile-path-pill {
  font-family: 'Orbitron', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(148, 163, 184, 0.85);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  direction: ltr;
}

.tile-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  color: #34d399;
  font-weight: 700;
}

.tile-status.is-offline {
  color: #f87171;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px #34d399;
}

.live-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}

@media (max-width: 600px) {
  .links-grid {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .tile-core {
    padding: 1.05rem 1rem 0.95rem;
    gap: 0.85rem;
  }

  .tile-logo-wrap {
    width: 58px;
    height: 58px;
    border-radius: 15px;
  }

  .tile-name {
    font-size: 1.02rem;
  }
}

.empty-portal,
.loading-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-glass);
  border-radius: 20px;
  color: var(--text-muted);
}

.neon-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 240, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spinSlow 0.9s linear infinite;
}

/* Login Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 6, 16, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: #0b1124;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 22px;
  padding: 1.5rem;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.15);
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-top h2 {
  font-size: 1.25rem;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.login-form .field {
  margin-bottom: 1rem;
}

.login-form label {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
}

.login-form input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.25);
}

.form-error {
  color: #f87171;
  font-size: 0.84rem;
  margin-bottom: 0.8rem;
}

.btn-neon-submit {
  width: 100%;
  padding: 0.75rem;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #050814;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.toast-item {
  background: rgba(11, 17, 36, 0.95);
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: 14px;
  font-size: 0.86rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
  .top-bar-inner {
    padding: 0.7rem 0.9rem;
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
    gap: 0.45rem;
  }

  .auth-group {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .btn-glass,
  .btn-neon-login,
  .btn-neon-sm {
    min-height: 44px;
    padding: 0.45rem 0.85rem;
    font-size: 0.84rem;
  }

  .notif-dropdown {
    position: fixed;
    top: 68px;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
  }

  .portal-main {
    padding: 1.25rem 0.9rem 3rem;
  }

  .hero-stage {
    padding: 0.5rem 0 1.75rem;
  }

  .neon-brand {
    font-size: clamp(1.9rem, 9vw, 2.8rem);
    letter-spacing: 1.5px;
  }

  .hero-subtitle {
    font-size: 0.95rem;
    padding: 0 0.5rem;
  }

  .links-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 0.85rem;
  }

  .link-tile {
    padding: 1.25rem 0.85rem;
    border-radius: 18px;
    gap: 0.75rem;
  }

  .tile-icon {
    width: 56px;
    height: 56px;
    font-size: 1.3rem;
    border-radius: 16px;
  }

  .tile-name {
    font-size: 1rem;
    word-break: break-word;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
