@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg-main: #0a0e17;
  --bg-surface: #111827;
  --bg-card: rgba(22, 30, 49, 0.75);
  --bg-card-hover: rgba(29, 41, 66, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.4);
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 25px rgba(79, 70, 229, 0.35);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand-font {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2.5rem;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.brand-logo-badge svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.brand-text p {
  font-size: 0.78rem;
  color: var(--text-dim);
}

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

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-tab-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.nav-tab-btn svg {
  width: 16px;
  height: 16px;
}

.nav-tab-btn:hover {
  color: #fff;
}

.nav-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border-subtle);
}

.user-avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #334155);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: #f1f5f9;
}

.user-meta-info {
  line-height: 1.25;
}

.user-meta-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
}

.user-role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

.role-super-admin {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.role-app-admin {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.role-user {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-icon-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Main Container */
.main-wrapper {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem;
  flex: 1;
}

.section-header {
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.section-header h2 {
  font-size: 1.85rem;
  font-weight: 700;
  color: #fff;
}

.section-header p {
  color: var(--text-muted);
  margin-top: 0.35rem;
  font-size: 0.95rem;
}

/* System Banner */
.domain-banner {
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.domain-banner-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.domain-pill {
  background: rgba(0, 0, 0, 0.4);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.9rem;
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* App Grid Launcher */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.75rem;
}

.app-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.app-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  opacity: 0;
  transition: var(--transition);
}

.app-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-active);
  background: var(--bg-card-hover);
}

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

.app-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

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

.icon-blue {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.35));
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.icon-purple {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(126, 34, 206, 0.35));
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
}

.icon-emerald {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.35));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.app-icon-wrapper svg {
  width: 28px;
  height: 28px;
}

.service-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 9px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

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

.status-offline {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-online .status-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-offline .status-dot {
  background: #ef4444;
}

.app-card h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
}

.app-card p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  flex: 1;
  margin-bottom: 1.5rem;
}

.app-metadata-bar {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.app-metadata-bar span strong {
  color: var(--text-muted);
}

.btn-launch {
  background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-launch svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s;
}

.btn-launch:hover {
  background: linear-gradient(135deg, #5b52f6 0%, #4f46e5 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

.btn-launch:hover svg {
  transform: translateX(4px);
}

/* Modals & Panels */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #131b2e;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.modal-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  margin-bottom: 1.75rem;
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/* Data Tables & Matrices */
.table-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-toolbar {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: rgba(0, 0, 0, 0.25);
  padding: 1rem 1.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
}

td {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.9rem;
  color: #e2e8f0;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Checkbox Switch Matrix */
.matrix-cell {
  text-align: center;
}

.custom-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Telemetry Cards */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

.telemetry-val {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  margin: 0.5rem 0;
  font-family: 'Outfit', sans-serif;
}

.telemetry-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Toast Notification */
#toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 200;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

#toast.success {
  border-color: rgba(16, 185, 129, 0.4);
}

#toast.error {
  border-color: rgba(239, 68, 68, 0.4);
}
