:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --bg-gradient: linear-gradient(135deg, #0F172A 0%, #1E1B4B 100%);
  --sidebar-bg: #0F172A;
  --sidebar-active: #1E293B;
  --card-bg: #FFFFFF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --border: #E2E8F0;
}

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

body {
  font-family: 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: #F1F5F9;
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* Overall App Shell */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  color: #F8FAFC;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #334155;
  flex-shrink: 0;
  user-select: none;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid #1E293B;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: #3B82F6;
  letter-spacing: -0.02em;
}

.sidebar-badge {
  background: #1E40AF;
  color: #93C5FD;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748B;
  padding: 0.75rem 0.75rem 0.25rem 0.75rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  color: #94A3B8;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.sidebar-item:hover {
  background: #1E293B;
  color: #F8FAFC;
}

.sidebar-item.active {
  background: #2563EB;
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-item .icon {
  font-size: 1.15rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #1E293B;
  background: #0B1120;
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2563EB;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.profile-info {
  display: flex;
  flex-direction: column;
}

.profile-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #F8FAFC;
}

.profile-role {
  font-size: 0.72rem;
  color: #64748B;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #F8FAFC;
}

/* Top App Header Bar */
.top-header {
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.page-title-group h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0F172A;
}

.header-status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 8px #22C55E;
}

/* Scrollable Content Workspace */
.content-body {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* SPA Page Section Switching */
.page-section {
  display: none;
}

.page-section.active-page {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dashboard Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-info .label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.metric-info .value {
  font-size: 2rem;
  font-weight: 800;
  color: #0F172A;
}

.metric-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.icon-blue { background: #EFF6FF; color: #2563EB; }
.icon-green { background: #F0FDF4; color: #16A34A; }
.icon-orange { background: #FFFBEB; color: #D97706; }
.icon-purple { background: #F3E8FF; color: #9333EA; }

/* Cards & Containers */
.card {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Table Styling */
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: #F8FAFC;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid #F1F5F9;
  font-size: 0.92rem;
}

tr:hover {
  background: #F8FAFC;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-expired { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover { background: #F1F5F9; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 520px;
  padding: 1.75rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: #334155;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ========================================================= */
/*                   RESPONSIVE / MOBILE UI                  */
/* ========================================================= */

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin-right: 0.5rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .hamburger-btn {
    display: block;
  }
  
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }
  
  .top-header {
    padding: 0 1rem;
    gap: 0.5rem;
    justify-content: flex-start;
  }

  .page-title-group {
    flex: 1;
  }

  .page-title-group h1 {
    font-size: 1.1rem;
  }

  .header-status-pill span:not(.status-dot) {
    display: none; /* Hide text on mobile, keep dot */
  }

  .header-status-pill {
    padding: 0.4rem;
    border-radius: 50%;
  }

  .content-body {
    padding: 1rem;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .modal {
    width: 95%;
    padding: 1.25rem;
    margin: 1rem;
  }
}

/* Enhancements */
.card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.01);
}
