:root {
  --ms-primary: #185FA5;
  --ms-primary-dark: #0C447C;
  --ms-primary-tint: #E6F1FB;
  --ms-staff: #3B6D11;
  --ms-staff-tint: #EAF3DE;
  --ms-sms: #993C1D;
  --ms-sms-tint: #FAECE7;
  --ms-academic: #3C3489;
  --ms-academic-tint: #EEEDFE;
  --ms-text: #1a1a1a;
  --ms-text-muted: #5f6368;
  --ms-border: #e3e6ea;
  --ms-sidebar-width: 250px;
  --ms-topbar-height: 60px;
  --ms-radius: 14px;
}

body {
  font-family: 'Open Sans', sans-serif;
  color: var(--ms-text);
  background: #f4f6f9;
}

/* Sidebar */
.ms-sidebar {
  width: var(--ms-sidebar-width);
  background: #fff;
  border-right: 1px solid var(--ms-border);
}

.ms-sidebar-brand {
  padding: 18px 20px;
  border-bottom: 1px solid var(--ms-border);
}

.ms-sidebar-brand-text {
  font-weight: 600;
  font-size: 15px;
}

.ms-nav {
  padding: 12px;
}

.ms-nav > .nav-item > .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ms-text);
  font-size: 14px;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 2px;
}

.ms-nav > .nav-item > .nav-link:hover,
.ms-nav > .nav-item > .nav-link[aria-expanded="true"] {
  background: var(--ms-primary-tint);
  color: var(--ms-primary-dark);
}

.ms-nav .bi-chevron-down {
  margin-left: auto;
  font-size: 12px;
  transition: transform 0.15s ease;
}

.ms-nav > .nav-item > .nav-link[aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}

.ms-subnav {
  padding-left: 30px;
}

.ms-subnav .nav-link {
  color: var(--ms-text-muted);
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 8px;
}

.ms-subnav .nav-link:hover {
  background: var(--ms-primary-tint);
  color: var(--ms-primary-dark);
}

.ms-nav .nav-link.active {
  background: var(--ms-primary-tint);
  color: var(--ms-primary-dark);
  font-weight: 600;
}

/* Top app bar */
.ms-topbar {
  /* min-height, not height: on narrow viewports the container-fluid's flex
     items wrap onto multiple lines (school name/subtitle, breadcrumb, user
     menu), and a fixed height clips at 60px with overflow:visible, so the
     wrapped rows spill past the topbar's box and sit on top of the page
     content that follows in normal flow instead of being pushed down. */
  min-height: var(--ms-topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--ms-border);
}

.ms-topbar .container-fluid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  min-height: 100%;
  padding-top: 8px;
  padding-bottom: 8px;
}

.ms-menu-btn {
  border: none;
  font-size: 20px;
  color: var(--ms-text);
}

.ms-topbar-title {
  font-size: 14px;
  font-weight: 600;
  flex-grow: 1;
}

.ms-topbar-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--ms-text-muted);
}

.ms-breadcrumb {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  font-size: 12px;
  color: var(--ms-text-muted);
}

.ms-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  border: 1px solid var(--ms-border);
  border-radius: 8px;
  padding: 6px 12px;
}

/* Content area */
.ms-main {
  /* Flex items default to min-width:auto, which stops them shrinking below
     the intrinsic width of their content (e.g. a wide legacy table) even
     when that content has its own overflow-x:auto scroll container. */
  min-width: 0;
  /* flex-grow-1 only sets flex-grow; flex-basis stays auto, which sizes
     this item off its content's preferred width. A wide table then makes
     .ms-main claim more than its share of the row, shrinking the sidebar
     instead of scrolling internally. Pinning the basis to 0 forces sizing
     from available flex space only, so .ms-table-scroll's overflow-x:auto
     actually kicks in. */
  flex-basis: 0;
}

.ms-content {
  padding: 24px;
}

.ms-footer {
  padding: 14px 24px;
  font-size: 12px;
  color: var(--ms-text-muted);
  border-top: 1px solid var(--ms-border);
}

/* KPI cards */
.ms-kpi-card {
  background: #fff;
  border-radius: var(--ms-radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.ms-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ms-kpi-value {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.ms-kpi-label {
  font-size: 12px;
  color: var(--ms-text-muted);
  margin: 0;
}

.ms-quicklink-card {
  background: #fff;
  border-radius: var(--ms-radius);
  padding: 18px;
}

.ms-quicklink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  text-decoration: none;
  margin: 0 8px 8px 0;
}

/* Legacy pages render plain, unwrapped <table> markup with no responsive
   handling of their own. ms-scripts.js wraps these tables in this container
   at runtime so a wide table scrolls within itself instead of forcing the
   whole page to scroll horizontally. */
.ms-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Sidebar collapse (desktop icon rail). Toggled by adding/removing
   ms-sidebar-collapsed on <html> - see ms-app.js. Scoped to the lg+
   breakpoint so it never interferes with the mobile offcanvas sidebar,
   which is a different layout mode entirely. */
@media (min-width: 992px) {
  .ms-sidebar {
    transition: width 0.2s ease;
  }

  html.ms-sidebar-collapsed .ms-sidebar {
    width: 64px;
  }

  html.ms-sidebar-collapsed .ms-sidebar-brand-text {
    display: none;
  }

  html.ms-sidebar-collapsed .ms-nav {
    padding: 12px 6px;
  }

  /* font-size:0 collapses the raw text node next to each icon to zero
     width with no markup changes; the icon's own font-size is reset
     below so it stays visible and centered. */
  html.ms-sidebar-collapsed .ms-nav > .nav-item > .nav-link {
    font-size: 0;
    justify-content: center;
    gap: 0;
    padding: 9px 0;
  }

  html.ms-sidebar-collapsed .ms-nav > .nav-item > .nav-link > i:first-child {
    font-size: 18px;
  }

  html.ms-sidebar-collapsed .ms-nav .bi-chevron-down,
  html.ms-sidebar-collapsed .ms-nav .collapse {
    display: none;
  }
}

.ms-collapse-btn {
  border: none;
  font-size: 20px;
  color: var(--ms-text);
}
