:root {
  --bg: #0b1220;
  --bg-alt: #111827;
  --surface: #172131;
  --surface-2: #1d2a3d;
  --surface-3: #223147;
  --text: #e5edf7;
  --muted: #94a7bd;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --accent: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #2a3a52;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --transition: all 0.25s ease;
}

body.light-theme {
  --bg: #eef3f9;
  --bg-alt: #dde7f3;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #edf3f9;
  --text: #142031;
  --muted: #5f7288;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --border: #d6e1ec;
  --shadow: 0 14px 35px rgba(20, 32, 49, 0.09);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg-alt));
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: rgba(11, 18, 32, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

body.light-theme .topbar {
  background: rgba(255, 255, 255, 0.88);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  margin: 0;
  font-size: 1.2rem;
}

.brand-subtitle {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

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

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--text);
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: var(--surface-2);
}

.primary-btn,
.outline-btn {
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

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

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

.outline-btn:hover {
  background: var(--surface-2);
}

.small-btn {
  width: fit-content;
  padding: 10px 14px;
  font-size: 0.92rem;
}

.sidebar {
  position: fixed;
  top: 0;
  left: -295px;
  width: 285px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  background: rgba(23, 33, 49, 0.98);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 60;
  transition: var(--transition);
}

body.light-theme .sidebar {
  background: rgba(255, 255, 255, 0.98);
}

.sidebar.open {
  left: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.08rem;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.nav-link {
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--text);
}

.nav-link:hover,
.nav-link.active {
  background: var(--surface-3);
  font-weight: 700;
}

.sidebar-footer {
  margin-top: 20px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 18px;
  padding: 14px;
  border: 1px solid var(--border);
}

.user-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.user-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.62);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 50;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
}

.main-content {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-card,
.section-block,
.search-bar-card,
.stat-card,
.project-card,
.directory-card,
.premium-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

body.light-theme .hero-card,
body.light-theme .section-block,
body.light-theme .search-bar-card,
body.light-theme .stat-card,
body.light-theme .project-card,
body.light-theme .directory-card,
body.light-theme .premium-card {
  background: var(--surface);
}

.hero-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 24px;
}

.badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #9dc3ff;
  font-weight: 700;
  font-size: 0.82rem;
}

body.light-theme .badge {
  color: var(--primary-dark);
}

.hero-card h2 {
  margin: 0 0 12px;
  font-size: 1.95rem;
  line-height: 1.15;
}

.hero-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.mini-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.mini-panel h3 {
  margin-top: 0;
}

.mini-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.section-block {
  padding: 20px;
}

.section-header {
  margin-bottom: 16px;
}

.section-header h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.section-header p {
  margin: 0;
  color: var(--muted);
}

.search-bar-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.search-bar-card input {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.search-bar-card input:focus {
  border-color: var(--primary);
}

.stats-grid,
.project-board,
.directory-grid,
.premium-grid {
  display: grid;
  gap: 16px;
}

.stat-card,
.project-card,
.directory-card,
.premium-card {
  padding: 18px;
}

.stat-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card h4 {
  font-size: 1.7rem;
  margin: 0 0 8px;
}

.stat-card p,
.project-card p,
.directory-card p,
.premium-card p {
  margin: 6px 0;
  color: var(--muted);
}

.warning-card {
  border-left: 5px solid var(--warning);
}

.project-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.project-number {
  font-weight: 700;
  color: #9dc3ff;
}

body.light-theme .project-number {
  color: var(--primary-dark);
}

.status-pill {
  display: inline-block;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.active {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.status-pill.warning {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}

.status-pill.danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

body.light-theme .status-pill.active {
  color: #15803d;
}

body.light-theme .status-pill.warning {
  color: #b45309;
}

body.light-theme .status-pill.danger {
  color: #b91c1c;
}

.project-card.flagged {
  border-left: 5px solid var(--danger);
}

.directory-card,
.premium-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lock-badge {
  display: inline-block;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--border);
}

.mobile-only {
  display: inline-flex;
}

@media (min-width: 768px) {
  .topbar {
    padding: 18px 26px;
  }

  .main-content {
    padding: 26px;
  }

  .hero-card {
    grid-template-columns: 1.5fr 1fr;
    align-items: center;
  }

  .search-bar-card {
    flex-direction: row;
    align-items: center;
  }

  .search-bar-card input {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-board,
  .directory-grid,
  .premium-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .app-shell {
    display: grid;
    grid-template-columns: 290px 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    left: 0;
    height: 100vh;
    box-shadow: none;
  }

  .overlay,
  .mobile-only {
    display: none;
  }

  .topbar {
    grid-column: 2;
    padding: 20px 30px;
  }

  .main-content {
    grid-column: 2;
    padding: 30px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .project-board {
    grid-template-columns: repeat(3, 1fr);
  }

  .directory-grid,
  .premium-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Dashboard live data cards */
.dashboard-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.dashboard-card-meta span {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.12);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.dashboard-card-link {
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
}

.dashboard-empty-card {
  grid-column: 1 / -1;
}

.dashboard-directory-summary {
  min-height: 220px;
}

.dashboard-item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 12px;
}

.dashboard-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
}

body.light-theme .dashboard-item-row {
  background: var(--surface-alt);
}

.dashboard-item-row span {
  color: var(--text);
  font-size: 0.9rem;
}

.dashboard-item-row strong {
  white-space: nowrap;
  font-size: 0.9rem;
}

.dashboard-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Command Center */
.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.breakdown-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.breakdown-card span {
  color: var(--muted);
  font-weight: 700;
}

.breakdown-card strong {
  font-size: 1.2rem;
}

@media (min-width: 768px) {
  .breakdown-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .breakdown-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Alerts */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-card {
  border-radius: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 0, 0, 0.05);
}

.alert-card.warning {
  background: rgba(255, 165, 0, 0.08);
}

.alert-card.info {
  background: rgba(29, 78, 216, 0.08);
}

.alert-card h4 {
  margin: 0 0 6px;
}

.alert-card p {
  margin: 0;
  color: var(--muted);
}

/* Navigation and page utility fixes */
.sidebar {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar .nav-menu { padding-bottom: 18px; }
.sidebar .nav-link { min-height: auto; }
.global-page-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.back-dashboard-btn { display: inline-flex; width: fit-content; align-items: center; justify-content: center; }
.clickable { cursor: pointer; }
.clickable:hover { transform: translateY(-1px); }
@media (max-width: 1099px) {
  .sidebar { padding-bottom: 28px; }
  .sidebar .nav-menu { gap: 6px; }
  .sidebar .nav-link { padding: 11px 13px; font-size: 0.95rem; }
}

/* Dashboard dependency alerts */
.alert-card.danger {
  background: rgba(220, 38, 38, 0.10);
}

.alert-card.success {
  background: rgba(22, 163, 74, 0.08);
}

/* Alert layout polish */
.alert-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.alert-card .alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.alert-card .outline-btn,
.alert-card .primary-btn {
  width: fit-content;
}
.status-pill.rejected {
  background: #f3f4f6;
  color: #374151;
}
body.dark-theme .status-pill.rejected,
body[data-theme="dark"] .status-pill.rejected {
  background: rgba(156, 163, 175, 0.18);
  color: #d1d5db;
}

/* Dashboard Customizer */
.dashboard-section-header-editable {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-customize-btn {
  flex: 0 0 auto;
}

.dashboard-card-hidden {
  display: none !important;
}

.dashboard-customize-modal.hidden {
  display: none !important;
}

.dashboard-customize-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 18px;
}

.dashboard-customize-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.dashboard-customize-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.dashboard-customize-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.dashboard-customize-header h3 {
  margin: 0 0 6px;
}

.dashboard-customize-header p {
  margin: 0;
  color: var(--muted);
}

.dashboard-customize-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-customize-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-alt);
}

.dashboard-customize-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.dashboard-customize-row input {
  width: 18px;
  height: 18px;
}

.dashboard-customize-row-actions,
.dashboard-customize-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dashboard-customize-actions {
  margin-top: 16px;
  justify-content: flex-end;
}

.tiny-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.82rem;
}

@media (max-width: 520px) {
  .dashboard-customize-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-customize-row-actions,
  .dashboard-customize-actions {
    width: 100%;
  }

  .dashboard-customize-actions button {
    flex: 1;
  }
}