:root {
  --apg-primary: #012b5b;      /* الأزرق الأساسي */
  --apg-primary-light: #064b92;
  --apg-gold: #f4b41a;         /* الذهبي */
  --apg-bg: #f5f7fb;
  --apg-card: #ffffff;
  --apg-text-main: #111827;
  --apg-text-muted: #6b7280;
  --radius-lg: 18px;
  --shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background: linear-gradient(135deg, #e5edf8, #f8fafc);
  color: var(--apg-text-main);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  background: radial-gradient(circle at top left, #123b7a, var(--apg-primary));
  color: #f9fafb;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fef9c3, var(--apg-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: var(--apg-primary);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-text-main {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-text-sub {
  font-size: 11px;
  opacity: 0.8;
}

.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  opacity: 0.7;
  margin-bottom: 6px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 999px;
  text-decoration: none;
  color: #e5e7eb;
  font-size: 13px;
  transition: 0.2s;
}

.nav-item a span.icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.nav-item a.active,
.nav-item a:hover {
  background: rgba(248, 250, 252, 0.16);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  opacity: 0.7;
}

/* ===== Main ===== */
.main {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--apg-text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-group {
  display: flex;
  gap: 8px;
}

.select-group select {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 6px 14px;
  font-size: 12px;
  background: #ffffff;
  min-width: 150px;
  outline: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--apg-gold), #fde68a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--apg-primary);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-info-name {
  font-size: 12px;
  font-weight: 600;
}

.user-info-role {
  font-size: 10px;
  color: var(--apg-text-muted);
}

/* ===== Content ===== */
.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Summary cards */
.cards-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: var(--apg-card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-title {
  font-size: 13px;
  color: var(--apg-text-muted);
}

.card-value {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(4, 120, 87, 0.08);
  color: #047857;
}

.card-note {
  font-size: 11px;
  color: var(--apg-text-muted);
}

.card-accent {
  position: absolute;
  inset-inline-start: -18px;
  bottom: -18px;
  width: 80px;
  height: 80px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #fef3c7, var(--apg-gold));
  opacity: 0.3;
}

/* Panels */
.panels-row {
  display: grid;
  grid-template-columns: 2.1fr 1.2fr;
  gap: 14px;
}

.panel {
  background: var(--apg-card);
  border-radius: var(--radius-lg);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow-soft);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
}

.panel-subtitle {
  font-size: 11px;
  color: var(--apg-text-muted);
}

/* Fake bar chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 180px;
  padding: 10px 4px 0;
}

.bar {
  flex: 1;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, var(--apg-gold), #fde68a);
  position: relative;
}

.bar.small { height: 30%; }
.bar.medium { height: 55%; }
.bar.high { height: 80%; }

.bar-label {
  position: absolute;
  bottom: -18px;
  inset-inline: 0;
  text-align: center;
  font-size: 10px;
  color: var(--apg-text-muted);
}

.bar-value {
  position: absolute;
  top: -18px;
  inset-inline: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--apg-primary);
}

/* Donut chart */
.donut-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.donut {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background:
    conic-gradient(#22c55e 0 260deg, #ef4444 260deg 310deg, #e5e7eb 310deg 360deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-inner {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--apg-primary);
}

.legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--apg-text-muted);
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-color.present { background: #22c55e; }
.legend-color.absent { background: #ef4444; }
.legend-color.not-recorded { background: #e5e7eb; }

/* Toolbar & forms */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.search-input {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 6px 12px;
  font-size: 12px;
  min-width: 200px;
  outline: none;
}

.btn-primary {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  background: var(--apg-primary);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  background: var(--apg-primary-light);
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e5f3ff;
  color: #1d4ed8;
  font-size: 10px;
  padding: 2px 8px;
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table thead {
  background: #f3f4f6;
}

.table th,
.table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid #e5e7eb;
}

.table tr:hover {
  background: #f9fafb;
}

/* Simple badges */
.badge-success {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.badge-danger {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .layout {
    grid-template-columns: 70px 1fr;
  }
  .brand-text, .sidebar-section-title, .sidebar-footer {
    display: none;
  }
  .nav-item a {
    justify-content: center;
    padding-inline: 0;
  }
  .nav-item a span.label {
    display: none;
  }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none; /* مبدئياً مخفي على الموبايل */
  }
  .cards-row {
    grid-template-columns: 1fr;
  }
  .panels-row {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }
}
