.area-login-credentials {
  display: grid;
  gap: 14px;
}

.area-login-credentials label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

.area-login-credentials input {
  width: 100%;
  min-height: 52px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.area-login-credentials input:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(30, 87, 140, 0.14);
}

body.area-report-system .login-panel {
  width: min(760px, 100%);
  max-width: 760px;
  margin: 0;
}

body.area-report-system .login-screen {
  overflow: auto;
  background: var(--bg);
}

body.area-report-system .login-screen::before {
  display: none;
}

body.area-report-system .login-form {
  gap: 18px;
}

body.area-report-system .sidebar .brand {
  width: 100%;
  min-height: 112px;
  padding: 16px;
  border-radius: 9px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.area-report-system .sidebar .brand-logo {
  width: min(230px, 100%);
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.topbar-title-group {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle,
.mobile-menu-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #b9c9d8;
  border-radius: 9px;
  background: #ffffff;
  color: var(--nav);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(8, 47, 84, 0.12);
}

.sidebar-toggle {
  position: absolute;
  z-index: 3;
  top: 20px;
  right: -17px;
  border-color: rgba(255, 255, 255, 0.3);
  background: var(--nav);
  color: #ffffff;
}

.sidebar-toggle svg,
.mobile-menu-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.sidebar-toggle svg {
  transition: transform 180ms ease;
}

.mobile-menu-toggle,
.sidebar-backdrop {
  display: none;
}

.sidebar-toggle:focus-visible,
.mobile-menu-toggle:focus-visible {
  outline: 3px solid rgba(207, 33, 39, 0.28);
  outline-offset: 3px;
}

@media (min-width: 1081px) {
  body.area-report-system .app-shell {
    grid-template-columns: 326px minmax(0, 1fr);
    transition: grid-template-columns 180ms ease;
  }

  body.area-report-system .app-shell.sidebar-collapsed {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  body.area-report-system .app-shell.sidebar-collapsed .sidebar {
    padding-inline: 11px;
  }

  body.area-report-system .app-shell.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
  }

  body.area-report-system .app-shell.sidebar-collapsed .sidebar .brand {
    min-height: 64px;
    padding: 7px 5px;
    border-radius: 7px;
  }

  body.area-report-system .app-shell.sidebar-collapsed .sidebar .brand-logo {
    width: 55px;
  }

  body.area-report-system .app-shell.sidebar-collapsed .nav a > span:last-child {
    display: none;
  }

  body.area-report-system .app-shell.sidebar-collapsed .nav a {
    padding-inline: 8px;
    grid-template-columns: 1fr;
    justify-items: center;
  }

  body.area-report-system .app-shell.sidebar-collapsed .nav a::before {
    left: -11px;
  }

}

@media (max-width: 1080px) {
  body.area-report-system.mobile-nav-open {
    overflow: hidden;
  }

  body.area-report-system .app-shell {
    display: block;
  }

  body.area-report-system .sidebar {
    position: fixed;
    z-index: 90;
    inset: 0 auto 0 0;
    width: min(88vw, 360px);
    height: 100dvh;
    padding: 22px 18px 18px;
    overflow-y: auto;
    border-top-width: 5px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 17px;
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform 200ms ease, visibility 200ms ease;
    box-shadow: 18px 0 46px rgba(3, 25, 47, 0.28);
  }

  body.area-report-system .app-shell.mobile-menu-open .sidebar {
    visibility: visible;
    transform: translateX(0);
  }

  body.area-report-system .sidebar-toggle {
    top: 15px;
    right: 14px;
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: none;
  }

  body.area-report-system .sidebar .brand {
    min-height: 112px;
    padding: 16px;
  }

  body.area-report-system .sidebar::before {
    display: flex;
  }

  body.area-report-system .sidebar .nav {
    width: 100%;
    min-width: 0;
    max-width: none;
    margin: 0;
    overflow: visible;
    display: grid;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    gap: 5px;
  }

  body.area-report-system .sidebar .nav a {
    min-height: 46px;
    padding: 7px 9px;
    grid-template-columns: 34px minmax(0, 1fr);
    font-size: 13px;
  }

  body.area-report-system .sidebar .nav a::before {
    left: -18px;
    top: 8px;
    bottom: auto;
    width: 4px;
    height: calc(100% - 16px);
  }

  body.area-report-system .sidebar-backdrop {
    position: fixed;
    z-index: 80;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(3, 24, 43, 0.54);
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease, visibility 200ms ease;
  }

  body.area-report-system .app-shell.mobile-menu-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.area-report-system .mobile-menu-toggle {
    flex: 0 0 auto;
    display: inline-flex;
  }

  body.area-report-system .topbar {
    align-items: center;
  }

  body.area-report-system .topbar-title-group {
    align-items: center;
  }
}

@media (max-width: 520px) {
  body.area-report-system .topbar-title-group {
    gap: 9px;
  }

  body.area-report-system .mobile-menu-toggle {
    width: 40px;
    height: 40px;
  }

  body.area-report-system .topbar-title-group h2 {
    font-size: 20px;
    line-height: 1.2;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.area-report-system .app-shell,
  body.area-report-system .sidebar,
  body.area-report-system .sidebar-backdrop,
  body.area-report-system .sidebar-toggle svg {
    transition: none;
  }
}

.area-report-filter-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Keep the all-levels qualifier together in the sidebar menu. */
.nav-label-nowrap {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .area-report-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .area-report-filter-grid { grid-template-columns: 1fr; }
}

.nr-library {
  display: grid;
  gap: 16px;
}

.nr-tabs {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #e9eef3;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nr-tabs button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.nr-tabs button:hover {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
}

.nr-tabs button.active {
  border-color: #c9d5e1;
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(9, 47, 84, 0.08);
}

.nr-filter-card,
.nr-result-panel,
.nr-empty {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.nr-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.nr-field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.nr-field > span {
  color: #40566e;
  font-size: 13px;
  font-weight: 800;
}

.nr-field select,
.nr-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #bfcddd;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.nr-field select:disabled {
  color: #8494a6;
  background: #f1f4f7;
}

.nr-report-ready {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}

.nr-download-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.nr-download,
.nr-primary,
.nr-open-student {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
}

.nr-download {
  padding: 8px 15px 8px 9px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.nr-download span {
  min-width: 39px;
  padding: 5px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font: 900 11px/1 var(--font-data);
}

.nr-download.pdf { background: #c62026; }
.nr-download.excel { background: #18724b; }
.nr-download:hover:not(:disabled) { filter: brightness(0.92); }

.nr-primary {
  min-width: 180px;
  margin-top: 16px;
  padding: 10px 22px;
  background: var(--primary);
}

.nr-form-hint {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nr-notice {
  margin: 0;
  padding: 12px 15px;
  border-left: 4px solid var(--primary);
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.nr-notice.success {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.nr-notice.error {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.nr-loading,
.nr-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.nr-loading i {
  width: 34px;
  height: 34px;
  border: 4px solid #dce5ee;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: nr-spin 800ms linear infinite;
}

.nr-empty span { display: block; font-size: 13px; }

.nr-section-head {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nr-section-head span { color: var(--muted); font-size: 12px; font-weight: 800; }
.nr-section-head h4 { margin: 3px 0 0; font-size: 20px; }

.nr-table-wrap { overflow: auto; }
.nr-table-wrap table { width: 100%; border-collapse: collapse; min-width: 820px; }
.nr-table-wrap th,
.nr-table-wrap td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.nr-table-wrap th { color: #fff; background: var(--nav); font-size: 12px; }
.nr-table-wrap td { font-size: 13px; }
.nr-table-wrap td small { display: block; margin-top: 3px; color: var(--muted); }
.nr-code { font-family: var(--font-data); }
.nr-open-student { padding: 8px 13px; background: var(--primary); }

@keyframes nr-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .nr-loading i { animation: none; }
}

@media (max-width: 1150px) {
  .nr-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .nr-library-head { align-items: flex-start; padding: 20px; }
  .nr-library-head > b { display: none; }
  .nr-filter-card,
  .nr-result-panel,
  .nr-empty { padding: 16px; }
  .nr-filter-grid { grid-template-columns: 1fr; }
  .nr-report-ready { align-items: stretch; flex-direction: column; }
  .nr-download-actions { justify-content: stretch; }
  .nr-download { flex: 1; justify-content: center; }
}

/* Match the original NIETS report-search flow: labels on the left, controls
   on the right, one field per row, and the action centered beneath the form. */
.nr-filter-card {
  padding: clamp(32px, 5vw, 68px) clamp(20px, 6vw, 108px) clamp(36px, 5vw, 60px);
}

.nr-filter-grid {
  width: min(100%, 940px);
  margin-inline: auto;
  grid-template-columns: 1fr;
  gap: 20px;
}

.nr-field {
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  align-items: center;
  column-gap: 18px;
  row-gap: 0;
}

.nr-field > span {
  text-align: right;
}

.nr-report-ready {
  width: min(100%, 940px);
  margin: 28px auto 0;
  padding-top: 0;
  border-top: 0;
  justify-content: center;
}

.nr-download-actions {
  justify-content: center;
}

.nr-filter-card > .nr-primary {
  display: block;
  margin: 28px auto 0;
}

.nr-filter-card > .nr-form-hint {
  width: min(100%, 940px);
  margin: 18px auto 0;
}

@media (max-width: 680px) {
  .nr-filter-card {
    padding: 24px 18px 28px;
  }

  .nr-filter-grid {
    gap: 14px;
  }

  .nr-field {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .nr-field > span {
    text-align: left;
  }

  .nr-report-ready {
    margin-top: 24px;
  }
}

/* On wide screens, centre the controls themselves.  The field labels sit in
   the reserved space to the left, matching the original NIETS form layout. */
@media (min-width: 1280px) {
  .nr-filter-grid,
  .nr-report-ready,
  .nr-filter-card > .nr-form-hint {
    width: min(100%, 485px);
  }

  .nr-field {
    display: block;
    position: relative;
  }

  .nr-field > span {
    position: absolute;
    top: 50%;
    right: calc(100% + 16px);
    width: 180px;
    transform: translateY(-50%);
    text-align: right;
  }
}
