/* ============================================================
   1. TOKENS & BASE
   ============================================================ */
:root {
  --navy: #074571;
  --blue: #0963a7;
  --green: #08a540;
  --red: #ef1727;
  --bg: #f3f6fb;
  --border: #dce3ec;
  --text: #12223a;
  --muted: #607083;
  --shadow: 0 4px 16px rgba(22, 49, 82, 0.08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Arial, sans-serif;
}
.layout {
  min-height: 100vh;
}

/* ============================================================
   2. SIDEBAR MENU CSS — START  ★ replaceable block ★
   Dynamic CoreUI ul/li structure:
     ul.sidebar-nav > li.nav-item | li.nav-group
     a.nav-link.nav-group-toggle  (group header, chevron via ::after)
     ul.nav-group-items           (submenu, opens on .nav-group.show)
   ============================================================ */

/* --- shell --- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  background: var(--navy);
  color: #fff;
  z-index: 30;
  transition: 0.25s;
  overflow-x: hidden;
  overflow-y: auto;
}
main {
  margin-left: 260px; /* tied to sidebar width */
  min-width: 0;
  transition: 0.25s;
}
.overlay {
  display: none; /* mobile drawer backdrop */
}

/* --- brand --- */
.brand {
  height: 66px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 3px 7px;
  white-space: nowrap;
}
.brand img:first-child {
  width: 102px;
  height: 54px;
  object-fit: contain;
}
.brand img:last-child {
  width: 128px;
  height: 56px;
  object-fit: contain;
}


/* ============================================
   Sidebar collapse — add to your style.css
   Works with your existing markup:
   .layout > aside.sidebar + #overlay + main
   ============================================ */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background: #1a3a5c;            /* keep your existing color */
    transition: margin-left 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
    z-index: 1050;
}

.layout main {
    flex: 1;
    min-width: 0;                   /* prevents flex overflow */
    transition: margin-left 0.3s ease;
}

/* ---------- Desktop: collapsed state ---------- */
@media (min-width: 992px) {
    .layout.sidebar-collapsed .sidebar {
        margin-left: -260px;        /* slides fully out of view */
    }

    .overlay {
        display: none;              /* no dark overlay on desktop */
    }
}

/* ---------- Mobile / tablet: off-canvas ---------- */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);   /* hidden by default */
    }

    .layout.sidebar-open .sidebar {
        transform: translateX(0);       /* slides in */
    }

    .overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 1040;                  /* below sidebar, above content */
    }

    .layout.sidebar-open .overlay {
        opacity: 1;
        visibility: visible;
    }

    /* stop background scrolling while the drawer is open */
    body.sidebar-locked {
        overflow: hidden;
    }
}

/* ---------- Toggle button ---------- */
.sidebar-toggle-btn {
    background: transparent;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    color: #1a3a5c;
}

.sidebar-toggle-btn:hover {
    background: #eef2f6;
}



/* --- nav list --- */
.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}
/* neutralise simplebar's injected wrappers, if present */
.sidebar-nav .simplebar-content { padding: 0 !important; }
.sidebar-nav .simplebar-wrapper { margin: 0 !important; }

.sidebar-nav .nav-item,
.sidebar-nav .nav-group {
  list-style: none;
}

/* top-level links & group toggles */
.sidebar-nav .nav-link {
  width: 100%;
  min-height: 48px;
  border: 0;
  background: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  font-size: 15px;
  white-space: nowrap;
}
.sidebar-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}
.sidebar-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.19);
}

/* icon column (font-awesome, replaces the 22px img) */
.sidebar-nav .nav-icon {
  width: 22px;
  flex: none;
  text-align: center;
  font-size: 17px;
}

/* chevron (replaces <b>⌄</b>) */
.sidebar-nav .nav-group-toggle::after {
  content: "⌄";
  margin-left: auto;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  transition: 0.2s;
}
.sidebar-nav .nav-group.show > .nav-group-toggle::after {
  transform: rotate(180deg);
}

/* submenu */
.sidebar-nav .nav-group-items {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  background: #063b61;
  transition: max-height 0.25s;
}
.sidebar-nav .nav-group.show > .nav-group-items {
  max-height: 260px; /* fits up to 5 items */
}
.sidebar-nav .nav-group-items .nav-link {
  min-height: 0;
  display: block;
  color: #dcecff;
  font-size: 14px;
  padding: 8px 16px 8px 49px;
  background: none;
}
.sidebar-nav .nav-group-items .nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
}
.sidebar-nav .nav-group-items .nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
/* no icons inside submenus (matches design) */
.sidebar-nav .nav-group-items .nav-icon {
  display: none;
}

/* --- help card --- */
.help {
  margin: 22px 8px;
  padding: 20px;
  border-radius: 15px;
  background: linear-gradient(145deg, #0968bd, #153a91);
  white-space: nowrap;
}
.help i {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #159ce9;
  font-style: normal;
  font-size: 20px;
}
.help h3 {
  margin: 11px 0 4px;
}
.help p {
  margin: 0;
  color: #e6f2ff;
  font-size: 12px;
  white-space: normal;
}
.help button {
  border: 0;
  border-radius: 22px;
  background: #2b98eb;
  color: #fff;
  padding: 10px 16px;
  margin-top: 14px;
  font-weight: 700;
  cursor: pointer;
}

/* --- collapsed sidebar (desktop) --- */
.layout.collapsed .sidebar {
  width: 78px;
}
.layout.collapsed main {
  margin-left: 78px;
}
.layout.collapsed .brand {
  gap: 0;
}
.layout.collapsed .brand img {
  width: 48px;
}
.layout.collapsed .sidebar-nav .nav-link {
  padding-left: 27px;
}
.layout.collapsed .sidebar-nav .nav-link span,
.layout.collapsed .sidebar-nav .nav-group-toggle::after,
.layout.collapsed .sidebar-nav .nav-group-items,
.layout.collapsed .help {
  display: none;
}

/* --- mobile sidebar (drawer) --- */
@media (max-width: 760px) {
  .sidebar {
    width: 260px;
    transform: translateX(-100%);
  }
  main,
  .layout.collapsed main {
    margin-left: 0;
  }
  .layout.collapsed .sidebar {
    width: 260px;
  }
  .layout.mobile-open .sidebar {
    transform: none;
  }
  .layout.mobile-open .overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: #0006;
    z-index: 25;
  }
  .layout.collapsed .brand img {
    width: auto;
  }
  .layout.collapsed .sidebar-nav .nav-link {
    padding-left: 16px;
  }
  .layout.collapsed .sidebar-nav .nav-link span {
    display: initial;
  }
  .layout.collapsed .sidebar-nav .nav-group-toggle::after {
    display: inline-block;
  }
  .layout.collapsed .sidebar-nav .nav-group-items {
    display: block;
  }
  .layout.collapsed .help {
    display: block;
  }
}

/* ============================================================
   SIDEBAR MENU CSS — END
   ============================================================ */

/* ============================================================
   3. TOPBAR
   ============================================================ */
.topbar {
  height: 70px;
  margin: 0 20px;
  background: #fff;
  border-radius: 0 0 5px 5px;
  box-shadow: 0 2px 10px #1c33501a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.welcome {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #355e91;
  font-size: 17px;
}
.welcome button {
  width: 42px;
  height: 42px;
  background: #fff;
  color: #1683d5;
  border: 1px solid #1683d5;
  border-radius: 5px;
  cursor: pointer;
}
.admin {
  border: 0;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  cursor: pointer;
}
.admin img {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  object-fit: cover;
}
.admin small {
  display: block;
  color: #697589;
}

/* ============================================================
   4. CONTENT / DASHBOARD
   ============================================================ */
.content {
  padding: 27px 26px 40px;
}
.breadcrumb {
  color: #11a23d;
  font-size: 17px;
  font-weight: 700;
  margin: 7px 0 18px;
}
.hero {
  min-height: 217px;
  border-radius: 13px;
  padding: 48px 26px;
  background: linear-gradient(90deg, #fff 0 47%, #ffffffe0 68%, #ffffff40),
    radial-gradient(circle at 88% 34%, #bde8f3, #ddf0dd 38%, #eef3fb 72%);
  box-shadow: var(--shadow);
}
.hero p {
  margin: 0;
  font-size: 15px;
}
.hero h1 {
  margin: 5px 0;
  color: #1762a8;
  font-size: 30px;
}
.hero span {
  color: var(--muted);
}
.hero i {
  display: block;
  width: 56px;
  height: 3px;
  background: #388cd2;
  margin-top: 16px;
}
.panel,
.records {
  margin-top: 36px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tab {
  min-width: 125px;
  padding: 11px 18px;
  border: 1px solid var(--border);
  background: #fff;
  color: #526174;
  font-weight: 700;
  cursor: pointer;
}
.tab.active {
  position: relative;
  background: #09609f;
  color: #fff;
  border-color: #09609f;
}
.tab.active:after {
  content: "";
  position: absolute;
  left: calc(50% - 7px);
  bottom: -7px;
  border: 7px solid transparent;
  border-top-color: #09609f;
  border-bottom: 0;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 177px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat-main {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  height: 123px;
  padding: 20px 18px;
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 69px;
  height: 69px;
  border-radius: 10px;
  color: #fff;
  font-size: 30px;
  font-weight: 700;
}
.c0 {
  background: linear-gradient(145deg, #6051f1, #4828d4);
}
.c1 {
  background: linear-gradient(145deg, #43e786, #0fa757);
}
.c2 {
  background: linear-gradient(145deg, #ff5864, #e72b3d);
}
.c3 {
  background: linear-gradient(145deg, #35aaf2, #1683db);
}
.stat strong {
  display: block;
  color: #0967cb;
  font-size: 28px;
  line-height: 1;
}
.stat:nth-child(2) strong {
  color: var(--green);
}
.stat:nth-child(3) strong {
  color: #e00000;
}
.stat p {
  min-height: 42px;
  margin: 7px 0 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}
.stat footer {
  height: 54px;
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  color: #0964b4;
  font-weight: 700;
}
.panel h2 {
  margin: 19px 0 10px;
  font-size: 21px;
}
.rankings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.rank-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.rank-card header {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
.rank-card header a {
  float: right;
  color: #0871c5;
  text-decoration: none;
  font-size: 12px;
}
.good {
  color: #0a9d36;
}
.bad {
  color: #ec2431;
}
.rank-card table {
  width: 100%;
  border-collapse: collapse;
}
.rank-card th,
.rank-card td {
  padding: 11px;
  border-bottom: 1px solid #eef1f5;
  text-align: left;
  font-size: 12px;
}
.progress {
  display: inline-block;
  width: 75px;
  height: 7px;
  margin-right: 7px;
  background: #e1e5e9;
  border-radius: 5px;
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  background: #08a63c;
}
.bad-progress i {
  background: #ff1823;
}
.filters {
  display: flex;
  align-items: center;
  gap: 13px;
  flex-wrap: wrap;
  padding-bottom: 16px;
}
.filters strong {
  font-size: 17px;
}
.filters select,
.filters input {
  height: 48px;
  min-width: 180px;
  padding: 0 15px;
  border: 1px solid #d8dee8;
  border-radius: 7px;
  background: #fff;
}
.filters input {
  min-width: 220px;
  margin-left: auto;
}
.table-scroll {
  overflow: auto;
  border-top: 1px solid #e7eaf0;
  padding-top: 26px;
}
.data-table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
}
.data-table th {
  padding: 14px 10px;
  background: #f3f1ff;
  color: #1c256b;
  text-align: left;
  font-size: 12px;
}
.data-table td {
  padding: 11px 10px;
  border-bottom: 1px solid #dce1e8;
  color: #111;
  font-size: 12px;
  white-space: nowrap;
}
#empty {
  display: none;
  text-align: center;
  color: var(--muted);
  padding: 25px;
}
.toast {
  position: fixed;
  right: 25px;
  bottom: 25px;
  z-index: 50;
  padding: 12px 18px;
  background: #0e385e;
  color: #fff;
  border-radius: 8px;
  transform: translateY(90px);
  opacity: 0;
  transition: 0.25s;
}
.toast.show {
  transform: none;
  opacity: 1;
}

/* ============================================================
   5. RESPONSIVE (non-sidebar — sidebar rules live in block 2)
   ============================================================ */
@media (max-width: 1120px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .rankings {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .topbar {
    height: 64px;
    margin: 0;
  }
  .welcome strong {
    font-size: 14px;
  }
  .admin span {
    display: none;
  }
  .content {
    padding: 18px 12px;
  }
  .hero {
    min-height: 185px;
    padding: 30px 20px;
  }
  .hero h1 {
    font-size: 24px;
  }
  .panel,
  .records {
    margin-top: 20px;
    padding: 13px;
  }
  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .tab {
    min-width: 0;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .rank-scroll {
    overflow: auto;
  }
  .rank-card table {
    min-width: 490px;
  }
  .filters select {
    flex: 1;
  }
  .filters input {
    width: 100%;
    margin-left: 0;
  }
}

/* ============================================================
   6. DASHBOARD CORRECTIONS
   ============================================================ */
.admin-wrap {
  position: relative;
}
.admin-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 54px;
  width: 155px;
  padding: 7px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 10px 28px #183b6326;
  z-index: 40;
}
.admin-menu.open {
  display: block;
}
.admin-menu a {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  color: #24374e;
  text-decoration: none;
  border-radius: 5px;
}
.admin-menu a:hover {
  background: #edf6ff;
  color: #0963a7;
}
.stat-icon {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  flex: none;
}
.rank-card table {
  width: 100%;
  min-width: 510px;
  table-layout: fixed;
}
.rank-card th,
.rank-card td {
  padding: 11px 8px;
  white-space: nowrap;
}
.rank-card th:nth-child(1) {
  width: 48px;
}
.rank-card th:nth-child(2) {
  width: 130px;
}
.rank-card th:nth-child(3),
.rank-card th:nth-child(4) {
  width: 88px;
}
.rank-card th:nth-child(5) {
  width: 145px;
}
.filters input {
  display: none;
}
.filters select {
  height: 48px;
  min-width: 190px;
  padding: 0 15px;
  border: 1px solid #d8dee8;
  border-radius: 7px;
  background: #fff;
}
.data-table {
  min-width: 650px;
}
.status {
  display: inline-block;
  min-width: 78px;
  padding: 5px 10px;
  border-radius: 15px;
  text-align: center;
  font-weight: 700;
}
.status-approved {
  background: #e3f7ea;
  color: #078638;
}
.status-pending {
  background: #fff2d8;
  color: #b46b00;
}
.status-rejected {
  background: #ffe5e8;
  color: #d8192e;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  color: var(--muted);
}
.pagination button {
  min-width: 34px;
  height: 34px;
  margin-left: 5px;
  border: 1px solid #d5dce6;
  border-radius: 5px;
  background: #fff;
  color: #31516f;
  cursor: pointer;
}
.pagination button.active {
  background: #0963a7;
  color: #fff;
  border-color: #0963a7;
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
@media (max-width: 760px) {
  .filters select {
    flex: 1;
  }
  .pagination {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }
}