:root {
  --bg-base: #0a0e17;
  --bg-card: rgba(19, 27, 44, 0.75);
  --bg-card-hover: rgba(26, 38, 62, 0.9);
  --border-color: rgba(255, 255, 255, 0.09);
  --border-highlight: rgba(56, 189, 248, 0.35);

  --accent-cyan: #38bdf8;
  --accent-cyan-hover: #0ea5e9;
  --accent-indigo: #818cf8;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.2);
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient dynamic background glow */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
}

.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.25) 0%, rgba(56, 189, 248, 0) 70%);
  top: -150px;
  right: -100px;
}

.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.2) 0%, rgba(129, 140, 248, 0) 70%);
  bottom: -200px;
  left: -150px;
}

.app-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------
   Login View
------------------------------------------------------------- */
.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: modalEnter 0.3s ease-out;
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.15);
}

.portal-badge-icon {
  font-size: 2rem;
}

.auth-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.auth-header p {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrap input {
  width: 100%;
  padding-right: 44px;
}

.btn-toggle-pw {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-toggle-pw:hover {
  color: var(--text-primary);
}

.auth-options {
  margin: 16px 0 20px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  display: none;
}

.checkbox-custom {
  width: 18px;
  height: 18px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.checkbox-label input:checked + .checkbox-custom {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.checkbox-label input:checked + .checkbox-custom::after {
  content: '✓';
  color: #000;
  font-size: 0.75rem;
  font-weight: 800;
}

.auth-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------
   Forms & Inputs
------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
  background: rgba(0, 0, 0, 0.5);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-col-icon {
  width: 84px;
  flex-shrink: 0;
}

.form-col-title {
  flex: 1;
}

.form-col-half {
  flex: 1;
}

/* -------------------------------------------------------------
   Buttons
------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #041226;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-cyan-hover);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 14px 20px;
  font-size: 1rem;
}

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

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(4, 18, 38, 0.3);
  border-top-color: #041226;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* -------------------------------------------------------------
   Alert Boxes
------------------------------------------------------------- */
.alert-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

/* -------------------------------------------------------------
   Portal Layout (Authenticated)
------------------------------------------------------------- */
.portal-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Navbar */
.portal-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(10, 14, 23, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 20px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 1.8rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-cyan);
  font-weight: 700;
}


.navbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Main Content */
.portal-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* Welcome Hero */
.welcome-hero {
  margin-bottom: 32px;
}

.greeting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.greeting-row h2 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.hero-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* -------------------------------------------------------------
   Services Grid & Cards
------------------------------------------------------------- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.service-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.service-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, transparent);
  transition: var(--transition);
}

.service-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  transform: translateY(-3px);
}

.service-card:hover::before {
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-indigo));
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-icon-badge {
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.card-status-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}


.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-emerald);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.status-indicator.offline {
  color: var(--accent-rose);
}

.status-indicator.offline .status-dot {
  background: var(--accent-rose);
}

.card-body {
  margin-bottom: 20px;
  flex: 1;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-url-btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--accent-cyan);
  margin-bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  word-break: break-all;
}

.card-url-btn:hover {
  background: rgba(56, 189, 248, 0.14);
  color: #fff;
}

.card-url-btn .url-copy-badge {
  font-size: 0.72rem;
  opacity: 0;
  color: var(--text-secondary);
  transition: opacity 0.15s ease;
  margin-left: 4px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.card-url-btn:hover .url-copy-badge {
  opacity: 1;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Card Actions */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-launch {
  flex: 1;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 10px 16px;
  font-weight: 700;
}

.btn-launch:hover {
  background: var(--accent-cyan);
  color: #041226;
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.card-tool-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.card-tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  margin: 40px auto;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

/* -------------------------------------------------------------
   Portal Footer
------------------------------------------------------------- */
.portal-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 14, 23, 0.6);
  padding: 20px 28px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-link-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.84rem;
  font-family: inherit;
  transition: var(--transition);
}

.footer-link-btn:hover {
  color: var(--accent-cyan);
}

/* -------------------------------------------------------------
   Modals
------------------------------------------------------------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  padding: 28px;
  animation: modalEnter 0.25s ease-out;
  z-index: 10;
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.modal-actions-between {
  justify-content: space-between;
}

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

.btn-danger-outline {
  background: rgba(244, 63, 94, 0.08);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger-outline:hover {
  background: rgba(244, 63, 94, 0.2);
  color: #fff;
  border-color: #fb7185;
}

.settings-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* -------------------------------------------------------------
   Toast Message
------------------------------------------------------------- */
.toast-message {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-cyan);
  color: var(--text-primary);
  padding: 12px 22px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(56, 189, 248, 0.3);
  z-index: 2000;
  opacity: 0;
  transition: all 0.25s ease-out;
  pointer-events: none;
}

.toast-message.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* -------------------------------------------------------------
   Mobile & Tablet Responsiveness
------------------------------------------------------------- */
@media (max-width: 768px) {
  .portal-navbar {
    padding: 12px 16px;
  }

  .btn-label {
    display: none;
  }

  .portal-main {
    padding: 20px 16px 40px;
  }

  .greeting-row h2 {
    font-size: 1.6rem;
  }

  .services-grid {
    grid-template-columns: 1fr;
  }

  .service-card {
    padding: 18px;
  }
}
