:root {
  --bg-app: #f4f6fa;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --border-light: #e2e8f0;
  --border-focus: #3b82f6;

  --color-primary-blue: #2563eb;
  --color-blue-dark: #1d4ed8;
  --color-green: #10b981;
  --color-green-dark: #059669;
  --color-purple: #8b5cf6;
  --color-indigo: #4f46e5;
  --color-rose: #f43f5e;
  --color-amber: #f59e0b;
  --color-sky: #0284c7;

  --text-dark: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-body);
  font-family: var(--font-sans);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================================
   1. AUTHENTICATION & LOGIN (MODERN CENTERED CARD)
   ========================================================================= */
.auth-wrapper {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #1e40af 0%, #0b1f42 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9999;
}

.auth-card-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  position: relative;
}

/* =========================================================================
   2. APP SHELL LAYOUT (IDENTICAL TO DESKTOP SOFTWARE)
   ========================================================================= */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* LEFT SIDEBAR */
.app-sidebar {
  width: 260px;
  background: #ffffff;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  z-index: 20;
}

.sidebar-brand {
  height: 72px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
}

.brand-logo-wrap {
  display: flex;
  flex-direction: column;
}

.brand-icon-sq {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #0f172a;
  display: block;
  line-height: 1.1;
}

.logo-text .accent {
  color: #2563eb;
}

.logo-sub {
  font-size: 9.5px;
  font-weight: 800;
  color: #2563eb;
  letter-spacing: 0.8px;
  display: block;
}

.brand-tagline {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-menu {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-heading {
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.8px;
  padding: 8px 10px 4px;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9.5px 12px;
  border-radius: 10px;
  color: #475569;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.nav-link:hover {
  background: #f8fafc;
  color: #0f172a;
}

.nav-link.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 700;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3.5px;
  border-radius: 0 4px 4px 0;
  background: #2563eb;
}

.nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.nav-link:hover .nav-icon {
  transform: scale(1.05);
}

.nav-icon.ic-purple { background: #f5f3ff; color: #8b5cf6; }
.nav-icon.ic-blue { background: #eff6ff; color: #2563eb; }
.nav-icon.ic-emerald { background: #ecfdf5; color: #10b981; }
.nav-icon.ic-indigo { background: #eef2ff; color: #4f46e5; }
.nav-icon.ic-sky { background: #f0f9ff; color: #0284c7; }
.nav-icon.ic-amber { background: #fffbeb; color: #d97706; }
.nav-icon.ic-gray { background: #f1f5f9; color: #64748b; }

.nav-badge-count {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 10px;
  background: #eff6ff;
  color: #2563eb;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.15s ease;
}

.sidebar-user-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.user-avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.user-info-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.user-info-text strong {
  display: block;
  font-size: 12.5px;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-role-pill {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
  background: #dbeafe;
  color: #1e40af;
  display: inline-block;
  text-transform: uppercase;
}

.btn-sidebar-signout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sidebar-signout:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* RIGHT MAIN WORKSPACE */
.app-main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: #f8fafc;
}

/* TOP STATUS BAR (ROYAL SAPPHIRE) */
.top-nav-bar {
  height: 64px;
  background: linear-gradient(135deg, #0b1f42 0%, #17387d 35%, #1d4ed8 70%, #2563eb 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(11, 31, 66, 0.15);
}

.top-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
}

.top-breadcrumb-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #93c5fd;
}

#breadcrumbTitle {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: #ffffff;
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge-chip.online {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot-emerald {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}

.top-unlimited-pill {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.3px;
}

.top-btn-download-hub {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.top-btn-download-hub:hover {
  background: rgba(255, 255, 255, 0.28);
}

.top-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.top-user-pill:hover {
  background: rgba(255, 255, 255, 0.2);
}

.top-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 800;
}

/* SCROLLABLE WORKSPACE */
.main-body-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  min-height: 0;
}

/* CONTENT PANEL CARDS */
.content-panel-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  padding: 24px 26px;
  margin-bottom: 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.panel-header h2 {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 3px;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* STATS GRID */
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat-tint-card {
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid transparent;
  transition: transform 0.15s ease;
}

.stat-tint-card:hover {
  transform: translateY(-2px);
}

.stat-tint-card.tint-blue { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.stat-tint-card.tint-green { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.stat-tint-card.tint-amber { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.stat-tint-card.tint-purple { background: #faf5ff; border-color: #e9d5ff; color: #6b21a8; }

.stat-tint-card .ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.stat-tint-card .lbl {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
  display: block;
}

.stat-tint-card .val {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
  margin-top: 2px;
  display: block;
}

/* QUICK ACTIONS GRID */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.action-tile-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-tile-card:hover {
  border-color: var(--color-primary-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.action-tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-tile-card strong {
  display: block;
  font-size: 13.5px;
  color: var(--text-dark);
}

.action-tile-card span {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* FORM CONTROLS */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-dark);
  font-size: 13.5px;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--color-primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* DURATION PILLS */
.duration-pills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.duration-pill-btn {
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border-light);
  background: #ffffff;
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.duration-pill-btn:hover:not(:disabled) {
  border-color: #93c5fd;
  background: #f8fafc;
}

.duration-pill-btn.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1e40af;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.duration-pill-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.duration-pill-btn .pill-sub {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.duration-pill-btn.active .pill-sub {
  color: #3b82f6;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-decoration: none;
}

.btn-outline {
  background: #ffffff;
  color: var(--text-body);
  border: 1px solid var(--border-light);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-dark);
}

.btn-success-sm {
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-success-sm:hover {
  background: #059669;
}

.btn-primary-blue {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary-blue:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-emerald-gradient {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

.btn-emerald-gradient:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-outline-sm {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-dark);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-outline-sm:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* TABLES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.portal-table th {
  padding: 12px 14px;
  background: #f8fafc;
  color: #64748b;
  font-weight: 700;
  border-bottom: 1px solid var(--border-light);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.portal-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-dark);
  vertical-align: middle;
}

.portal-table tr:hover td {
  background: #fbfcfe;
}

/* CHIPS & BADGES */
.chip-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.chip-green { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.chip-amber { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.chip-rose { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }
.chip-blue { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.chip-gray { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

/* PERMISSION TILES & SWITCHES */
.perm-card {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.perm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}

.perm-row:last-child {
  border-bottom: none;
}

.perm-info strong {
  display: block;
  font-size: 13.5px;
  color: var(--text-dark);
}

.perm-info span {
  font-size: 12px;
  color: var(--text-muted);
}

/* TOGGLE SWITCH */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  border-radius: 24px;
  transition: 0.25s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.25s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #2563eb;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 18px 24px;
  background: linear-gradient(135deg, #0d234a 0%, #1e40af 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}

.btn-close-modal {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.btn-close-modal:hover {
  background: rgba(255, 255, 255, 0.35);
}

.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* TOAST */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 99999;
}
