/* ==============================================================================
   VPS Unified Portal - World-Class Design System
   Inspired by Linear, Raycast, and Vercel modern dark aesthetic
   ============================================================================== */

:root {
  --bg-base: #060911;
  --bg-surface: #0c1222;
  --bg-card: rgba(14, 21, 38, 0.85);
  --bg-card-hover: rgba(20, 31, 56, 0.95);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(99, 102, 241, 0.5);
  --text-pure: #ffffff;
  --text-main: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --grad-brand: linear-gradient(135deg, #6366f1 0%, #3b82f6 50%, #06b6d4 100%);
  --grad-emerald: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --grad-amber: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --grad-indigo: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);

  --accent-blue: #38bdf8;
  --accent-green: #34d399;
  --accent-amber: #fbbf24;
  --accent-rose: #fb7185;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
}

html {
  background-color: var(--bg-base);
  -webkit-text-size-adjust: 100%;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.2), transparent 70%),
    radial-gradient(ellipse 60% 40% at 90% 90%, rgba(6, 182, 212, 0.1), transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ==============================================================================
   Top Navigation
   ============================================================================== */
.navbar {
  background: rgba(10, 15, 29, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  padding: 1rem 2.5rem;
  padding-top: max(0.85rem, env(safe-area-inset-top));
  padding-left: max(1.5rem, calc(1rem + env(safe-area-inset-left)));
  padding-right: max(1.5rem, calc(1rem + env(safe-area-inset-right)));
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.brand-badge-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--grad-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-pure);
  letter-spacing: -0.02em;
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--accent-blue);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.user-tag {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
}

.live-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.8)); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

.btn-quit {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-quit:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--text-pure);
}

/* ==============================================================================
   Layout Container
   ============================================================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  padding-left: max(1.25rem, calc(1rem + env(safe-area-inset-left)));
  padding-right: max(1.25rem, calc(1rem + env(safe-area-inset-right)));
  flex: 1;
  width: 100%;
}

/* Status Strip */
.status-strip {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  margin-bottom: 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-subtle);
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
}

.status-meta-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-meta-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-pure);
}

/* Section Header */
.section-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.section-title-wrap h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-pure);
  letter-spacing: -0.02em;
}

.section-title-wrap p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.btn-refresh {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-refresh:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-pure);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ==============================================================================
   Service Launchpad Cards
   ============================================================================== */
.services-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.75rem;
  margin-bottom: 3rem;
}

.app-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.app-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-brand);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.app-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-subtle), var(--shadow-glow);
}

.app-card:active {
  transform: translateY(-1px) scale(0.995);
}

.app-card:hover::before {
  opacity: 1;
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.app-icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.app-icon-proxy { background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%); color: white; }
.app-icon-magnet { background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); color: white; }
.app-icon-charity { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); color: white; }

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
}

.health-pill.online {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.health-pill.offline {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-rose);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.app-title-group {
  margin-bottom: 0.85rem;
}

.app-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-pure);
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}

.app-port-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.app-summary {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  min-height: 48px;
}

.app-auth-feature {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}

.app-auth-feature.level-a { color: var(--accent-blue); }
.app-auth-feature.level-d { color: var(--accent-amber); }

/* Buttons inside Card */
.app-action-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-launch-primary {
  width: 100%;
  background: var(--grad-brand);
  color: var(--text-pure);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
  transition: all 0.2s ease;
}

.btn-launch-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.55);
  color: var(--text-pure);
}

.btn-launch-primary:active {
  transform: translateY(0px) scale(0.98);
}

.card-secondary-links {
  display: flex;
  gap: 0.6rem;
}

.btn-sub-link {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.btn-sub-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-pure);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ==============================================================================
   Login Page
   ============================================================================== */
.login-stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  padding-top: max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  padding-left: max(1.25rem, calc(1rem + env(safe-area-inset-left)));
  padding-right: max(1.25rem, calc(1rem + env(safe-area-inset-right)));
  position: relative;
}

.login-glass-card {
  width: 100%;
  max-width: 420px;
  background: rgba(14, 21, 38, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 50px rgba(99, 102, 241, 0.15);
  position: relative;
}

.login-glass-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-brand);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.login-head {
  text-align: center;
  margin-bottom: 2.25rem;
}

.login-icon-sphere {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--grad-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.login-head h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-pure);
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.login-head p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.field-group {
  margin-bottom: 1.5rem;
}

.field-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.input-container {
  position: relative;
}

.text-input {
  width: 100%;
  background: rgba(6, 9, 17, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  padding-right: 3rem;
  color: var(--text-pure);
  font-size: 16px; /* Must be >= 16px to prevent iOS Safari auto-zoom */
  outline: none;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

.text-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.btn-eye {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-eye:hover {
  color: var(--text-pure);
}

.btn-signin {
  width: 100%;
  background: var(--grad-brand);
  color: var(--text-pure);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
  transition: all 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-signin:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn-signin:active {
  transform: scale(0.98);
}

.btn-signin:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.error-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
  display: none;
}

.login-footnote {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Footer */
.footer-wrap {
  text-align: center;
  padding: 1.75rem;
  padding-bottom: max(1.75rem, calc(1rem + env(safe-area-inset-bottom)));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  border-top: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ==============================================================================
   iOS Mobile Responsive Adaptations (< 768px and < 480px)
   ============================================================================== */

@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .brand {
    gap: 0.65rem;
  }

  .brand-badge-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .brand-badge-icon svg {
    width: 18px;
    height: 18px;
  }

  .brand-text h1 {
    font-size: 1rem;
  }

  .brand-text p {
    font-size: 0.65rem;
  }

  .nav-actions {
    gap: 0.5rem;
  }

  .user-tag {
    padding: 0.35rem 0.65rem;
    font-size: 0.76rem;
    gap: 0.4rem;
  }

  .btn-quit {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    min-height: 36px;
    touch-action: manipulation;
  }

  .container {
    padding: 1.25rem 1rem;
    padding-left: max(0.85rem, env(safe-area-inset-left));
    padding-right: max(0.85rem, env(safe-area-inset-right));
  }

  .status-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    margin-bottom: 1.5rem;
  }

  .status-item:last-child {
    grid-column: 1 / -1;
  }

  .status-icon {
    width: 30px;
    height: 30px;
  }

  .status-meta-title {
    font-size: 0.68rem;
  }

  .status-meta-val {
    font-size: 0.82rem;
  }

  .section-title-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .section-title-wrap h2 {
    font-size: 1.2rem;
  }

  .section-title-wrap p {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .btn-refresh {
    width: 100%;
    justify-content: center;
    padding: 0.65rem 1rem;
    font-size: 0.84rem;
    min-height: 42px;
    touch-action: manipulation;
  }

  .services-deck {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
  }

  .app-card {
    padding: 1.35rem 1.15rem;
    border-radius: 16px;
    touch-action: manipulation;
  }

  .card-header-bar {
    margin-bottom: 1rem;
  }

  .app-icon-wrap {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .app-icon-wrap svg {
    width: 22px;
    height: 22px;
  }

  .health-pill {
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
  }

  .app-name {
    font-size: 1.12rem;
  }

  .app-port-tag {
    font-size: 0.72rem;
  }

  .app-summary {
    font-size: 0.86rem;
    min-height: auto;
    margin-bottom: 0.85rem;
    line-height: 1.5;
  }

  .app-auth-feature {
    font-size: 0.76rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1.15rem;
  }

  .btn-launch-primary {
    padding: 0.75rem 1rem;
    min-height: 48px;
    font-size: 0.95rem;
    touch-action: manipulation;
  }

  .card-secondary-links {
    gap: 0.5rem;
  }

  .btn-sub-link {
    min-height: 42px;
    padding: 0.5rem;
    font-size: 0.78rem;
    touch-action: manipulation;
  }

  .login-stage {
    padding: 1.25rem 1rem;
  }

  .login-glass-card {
    padding: 2rem 1.25rem;
    border-radius: 20px;
  }

  .login-icon-sphere {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    margin-bottom: 1rem;
  }

  .login-head {
    margin-bottom: 1.75rem;
  }

  .login-head h2 {
    font-size: 1.35rem;
  }

  .login-head p {
    font-size: 0.82rem;
  }

  .btn-signin {
    min-height: 48px;
    font-size: 0.95rem;
  }
}

@media (max-width: 390px) {
  .brand-text p {
    display: none;
  }

  .user-tag span:nth-child(2) {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .card-secondary-links {
    flex-direction: column;
  }
}
