:root {
  --bg-page: #0a0f1c;
  --bg-sidebar: #0d1425;
  --bg-card: #131c31;
  --bg-elevated: #192540;
  --bg-input: #0b1120;
  --border-color: rgba(148, 163, 184, 0.14);
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --gradient-brand: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
  --text-white: #f8fafc;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #38bdf8;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', 'Inter', sans-serif;
  color: var(--text-white);
}

.portal-loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(124, 58, 237, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.portal-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.portal-sidebar {
  width: 268px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 40;
}

.sidebar-brand {
  padding: 1.35rem 1.35rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--gradient-brand);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  display: block;
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: #a78bfa;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.portal-nav {
  padding: 1.1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.portal-nav-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
}

.portal-nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.portal-nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.38);
  color: #fff;
  font-weight: 600;
}

.portal-nav-item.active svg {
  color: #a78bfa;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
}

.sidebar-user-box {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta {
  overflow: hidden;
}

.user-meta strong {
  display: block;
  font-size: 0.86rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}

.logout-btn:hover {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

/* Main Area */
.portal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.portal-topbar {
  height: 72px;
  background: rgba(13, 20, 37, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mobile-sidebar-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.topbar-crumb {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topbar-left h2 {
  font-size: 1.2rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

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

.notif-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: 46px;
  width: 340px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.55);
  padding: 0.85rem;
  z-index: 60;
}

.portal-content {
  padding: 2rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Common UI Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s;
}

.btn-sm {
  padding: 0.48rem 0.9rem;
  font-size: 0.82rem;
}

.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: #fff;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.15rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-purple { background: rgba(124, 58, 237, 0.16); color: #c4b5fd; }
.kpi-green { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.kpi-amber { background: rgba(245, 158, 11, 0.16); color: #fbbf24; }
.kpi-red { background: rgba(239, 68, 68, 0.16); color: #f87171; }

.kpi-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.kpi-val {
  font-family: 'Outfit', sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-pending_approval {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.status-under_review, .status-approved {
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.status-deploying {
  background: rgba(167, 139, 250, 0.16);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.4);
}

.status-active {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-rejected, .status-deployment_failed, .status-failed {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Forms */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.72rem 0.95rem;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

textarea.form-control {
  min-height: 92px;
  resize: vertical;
}

.form-hint {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 0.32rem;
}

.logo-dropzone {
  border: 2px dashed rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.logo-dropzone:hover, .logo-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.06);
}

.logo-preview-thumb {
  max-height: 76px;
  max-width: 200px;
  margin: 0.85rem auto 0;
  border-radius: 8px;
  display: block;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px;
}

/* Request & Website Cards */
.item-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.request-card, .website-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
}

.request-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.code-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: #a78bfa;
  background: rgba(124, 58, 237, 0.14);
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
}

.info-banner {
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.15rem;
  font-size: 0.88rem;
  color: #ddd6fe;
  margin-bottom: 1.5rem;
}

.rejection-box {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fecaca;
  font-size: 0.86rem;
}

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

.modal-box {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-head {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
}

.modal-foot {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.cred-field {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  word-break: break-all;
}

.portal-two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1.5rem;
}

.sidebar-overlay-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 35;
}

.sidebar-overlay-backdrop.open {
  display: block;
}

.cred-field code {
  font-family: 'JetBrains Mono', monospace;
  color: #fff;
  font-size: 0.92rem;
}

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.45);
}

@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .portal-sidebar {
    position: fixed;
    left: -280px;
    transition: left 0.25s ease;
  }
  .portal-sidebar.open {
    left: 0;
  }
  .sidebar-close-btn, .mobile-sidebar-btn {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .kpi-grid, .form-row, .portal-two-col-grid {
    grid-template-columns: 1fr;
  }
  .portal-content {
    padding: 1.15rem 1rem;
  }
  .portal-topbar {
    padding: 0 0.85rem;
    gap: 0.5rem;
  }
  .topbar-left h2 {
    font-size: 1rem;
  }
  .notif-dropdown {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    top: 68px;
    width: auto;
  }
  .request-card, .website-card, .card {
    padding: 1.15rem;
  }
  .modal-head, .modal-body, .modal-foot {
    padding: 1rem 1.15rem;
  }
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}

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

