:root {
  --rg-red: #8B1A2B;
  --rg-red-dark: #5C101C;
  --rg-red-soft: #B4233A;
  --rg-black: #0E0E10;
  --rg-ink: #1A1A1F;
  --rg-gold: #C9A227;
  --rg-gold-soft: #E3C56B;
  --rg-orange: #D94B3A;
  --rg-cream: #F8F3EC;
  --rg-paper: #FFFDF9;
  --rg-muted: #6B6560;
  --rg-line: #E8DFD2;
  --rg-sidebar: #14090C;
  --rg-shadow: 0 18px 50px rgba(14, 14, 16, .12);
  --rg-radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--rg-ink);
  background: var(--rg-cream);
}
h1, h2, h3, h4, .font-display {
  font-family: Cinzel, Georgia, serif;
  letter-spacing: .02em;
}

.bg-rg { background: var(--rg-red); }
.text-rg { color: var(--rg-red); }
.text-gold { color: var(--rg-gold); }
.btn-rg {
  background: linear-gradient(180deg, var(--rg-red-soft), var(--rg-red));
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: .7rem 1.4rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(139, 26, 43, .28);
}
.btn-rg:hover { color: #fff; filter: brightness(1.08); }
.btn-gold {
  background: linear-gradient(180deg, var(--rg-gold-soft), var(--rg-gold));
  color: var(--rg-black);
  border: 0;
  border-radius: 999px;
  padding: .7rem 1.4rem;
  font-weight: 700;
}
.btn-gold:hover { color: var(--rg-black); }
.btn-outline-rg {
  border: 1.5px solid var(--rg-gold);
  color: var(--rg-gold);
  border-radius: 999px;
  padding: .65rem 1.3rem;
  background: transparent;
}
.btn-outline-rg:hover { background: var(--rg-gold); color: var(--rg-black); }

/* ========== PUBLIC ========== */
.public-topbar {
  background: var(--rg-black);
  color: #cfc6b8;
  font-size: .85rem;
  letter-spacing: .04em;
}
.public-topbar a { color: var(--rg-gold-soft); text-decoration: none; }
.public-nav {
  background: rgba(253, 248, 242, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rg-line);
}
.public-nav .navbar-brand { color: var(--rg-red); font-weight: 700; }
.public-nav .nav-link {
  color: var(--rg-ink) !important;
  font-weight: 600;
  padding: .7rem 1rem !important;
}
.public-nav .nav-link:hover, .public-nav .nav-link.active { color: var(--rg-red) !important; }
.brand-logo { height: 52px; width: auto; }

.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  color: #fff;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(201,162,39,.25), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(139,26,43,.45), transparent 42%),
    linear-gradient(160deg, #0E0E10 0%, #2A0C14 50%, #8B1A2B 100%);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../img/logo.png");
  background-repeat: no-repeat;
  background-position: 112% 18%;
  background-size: 520px;
  opacity: .12;
  pointer-events: none;
}
.hero-crest {
  width: min(280px, 70vw);
  filter: drop-shadow(0 20px 40px rgba(0,0,0,.45));
}
.hero-kicker {
  color: var(--rg-gold-soft);
  text-transform: uppercase;
  letter-spacing: .28em;
  font-size: .78rem;
  font-weight: 700;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  margin: .4rem 0;
}
.hero-motto {
  border-top: 1px solid rgba(201,162,39,.4);
  border-bottom: 1px solid rgba(201,162,39,.4);
  display: inline-block;
  padding: .45rem 0;
  letter-spacing: .18em;
  font-size: .92rem;
  color: var(--rg-gold-soft);
}
.hero-meta { color: #d9d0c4; }

.stat-strip {
  background: var(--rg-red);
  color: #fff;
  margin-top: -40px;
  position: relative;
  z-index: 2;
  border-radius: var(--rg-radius);
  box-shadow: var(--rg-shadow);
}
.stat-strip .stat-num {
  font-family: Cinzel, serif;
  font-size: 1.8rem;
  color: var(--rg-gold-soft);
}
.section-kicker {
  color: var(--rg-red);
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  font-size: .75rem;
}
.gold-rule {
  width: 64px;
  height: 3px;
  background: var(--rg-gold);
  margin: .8rem 0 1.2rem;
}
.card-rg {
  background: var(--rg-paper);
  border: 1px solid var(--rg-line);
  border-radius: var(--rg-radius);
  box-shadow: 0 10px 30px rgba(20, 10, 12, .05);
  overflow: hidden;
}
.card-rg:hover { transform: translateY(-4px); transition: .2s ease; }
.icon-disc {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: #f4e6e9; color: var(--rg-red); font-size: 1.4rem;
}
.value-card {
  border-top: 4px solid var(--rg-gold);
  min-height: 180px;
}
.news-card img, .gallery-grid img { width: 100%; height: 220px; object-fit: cover; }
.gallery-grid img { height: 180px; border-radius: 12px; }
.page-hero {
  background: linear-gradient(135deg, var(--rg-black), var(--rg-red-dark) 70%);
  color: #fff;
  padding: 5.5rem 0 3rem;
}
.public-footer {
  background: var(--rg-black);
  color: #cfc6b8;
}
.public-footer h5, .public-footer h6 { color: #fff; }
.public-footer a { color: var(--rg-gold-soft); text-decoration: none; }
.footer-crest { height: 86px; }

/* ========== APP SHELL ========== */
.app-body { background: #f4eee6; }
.app-sidebar {
  width: 270px;
  background: var(--rg-sidebar);
  color: #d7cfc6;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: auto;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-sidebar::-webkit-scrollbar,
.app-nav::-webkit-scrollbar { width: 8px; }
.app-sidebar::-webkit-scrollbar-thumb,
.app-nav::-webkit-scrollbar-thumb {
  background: rgba(201, 162, 39, .45);
  border-radius: 8px;
}
.app-brand {
  flex: 0 0 auto;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; gap: .8rem; align-items: center;
}
.app-brand img { height: 46px; }
.app-brand .name { color: #fff; font-weight: 700; line-height: 1.1; }
.app-brand .role { color: var(--rg-gold); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.app-nav {
  padding: .8rem .55rem .8rem .8rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.select-multi { min-height: 8.5rem; }
.check-box-panel, .class-pick {
  border: 1px solid var(--rg-line);
  border-radius: 12px;
  padding: .75rem .9rem;
  background: #fff;
  max-height: 340px;
  overflow-y: auto;
}
.class-pick-group + .class-pick-group { margin-top: .85rem; padding-top: .75rem; border-top: 1px dashed var(--rg-line); }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .2rem .6rem;
}
.app-nav a {
  display: flex; align-items: center; gap: .7rem;
  color: #d7cfc6; text-decoration: none;
  padding: .62rem .8rem; border-radius: 12px; font-weight: 600; font-size: .94rem;
}
.app-nav a:hover, .app-nav a.active,
.app-sidebar-foot a:hover {
  background: rgba(139, 26, 43, .55);
  color: #fff;
}
.app-sidebar-foot {
  flex: 0 0 auto;
  margin-top: 0;
  padding: .4rem .8rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.08);
  background: var(--rg-sidebar);
}
.app-sidebar-foot a {
  display: flex; align-items: center; gap: .7rem;
  color: #d7cfc6; text-decoration: none;
  padding: .62rem .8rem; border-radius: 12px; font-weight: 600; font-size: .94rem;
}
.app-nav .nav-label,
.app-sidebar-foot .nav-label {
  font-size: .7rem; letter-spacing: .16em; text-transform: uppercase;
  color: #8d8378; padding: .9rem .8rem .3rem;
}
.app-main { margin-left: 270px; min-height: 100vh; }
.app-top {
  background: #fffdf9;
  border-bottom: 1px solid var(--rg-line);
  padding: .75rem 1.4rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 30;
}
.app-content { padding: 1.4rem; }
.kpi {
  background: #fff;
  border-radius: var(--rg-radius);
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--rg-line);
  box-shadow: 0 8px 24px rgba(20,10,12,.04);
}
.kpi .kpi-label { color: var(--rg-muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi .kpi-value { font-family: Cinzel, serif; font-size: 1.55rem; margin-top: .2rem; }
.table-rg thead th {
  background: #f7f0e6;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #5c534c;
}
.table-rg tbody td { vertical-align: middle; }
.search-box { max-width: 340px; }
.year-select { min-width: 160px; }
.avatar-sm {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--rg-red); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.empty-icon { font-size: 2.4rem; color: var(--rg-gold); }
.receipt-paper {
  max-width: 780px; margin: 0 auto; background: #fff;
  border: 2px solid var(--rg-gold); padding: 2rem;
}
.lock-banner {
  background: #fff3cd; border: 1px solid #ffe69c; color: #664d03;
  border-radius: 12px; padding: .7rem 1rem;
}

.app-sidebar-backdrop {
  display: none;
}
.app-sidebar-close {
  display: none;
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #d7cfc6;
  font-size: 1.2rem;
  line-height: 1;
  padding: .2rem .35rem;
}

@media (max-width: 991px) {
  .app-sidebar {
    width: min(280px, 88vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  .app-sidebar.open {
    transform: none;
    box-shadow: 12px 0 40px rgba(0, 0, 0, .4);
  }
  .app-sidebar-close { display: inline-flex; }
  .app-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(14, 14, 16, .5);
    z-index: 1035;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .app-sidebar.open ~ .app-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .app-main { margin-left: 0; }
  .hero::before { background-size: 280px; background-position: 120% 90%; }
  body.sidebar-open { overflow: hidden; }
}
div.dt-container { font-size: .92rem; }
div.dt-container .dt-search input,
div.dt-container .dt-length select {
  border: 1px solid var(--rg-line);
  border-radius: 10px;
  padding: .35rem .7rem;
}
div.dt-container .dt-paging .dt-paging-button.current {
  background: var(--rg-red) !important;
  color: #fff !important;
  border: 0 !important;
}
.report-wrap .card-rg:hover { transform: none; }
.report-section h5 { margin-bottom: .4rem; }
.modal { z-index: 1080; }
.modal-backdrop { z-index: 1070; }
.modal-dialog-scrollable > form.modal-content {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}
.modal-dialog-scrollable > form.modal-content > .modal-body {
  overflow-y: auto;
}
#editStudentModal .modal-header,
#editStudentModal .modal-footer {
  flex-shrink: 0;
  background: #fff;
}
#editStudentModal .modal-footer {
  justify-content: flex-end;
  gap: .5rem;
  padding: .9rem 1.15rem;
  border-top: 1px solid var(--rg-line);
}
#editStudentModal .modal-footer .btn-rg {
  min-width: 14rem;
}

@media print {
  .no-print, .dt-layout-row:has(.dt-search), .dt-search, .dt-length, .dt-paging, .dt-info { display: none !important; }
  .app-sidebar, .app-top { display: none !important; }
  .app-main { margin: 0 !important; }
  body { background: #fff; }
  .report-print-head { display: block !important; }
  .report-section { break-inside: avoid; page-break-inside: avoid; }
  body, h1, h2, h3, h4, h5, h6, .font-display, .kpi-value {
    font-family: "Source Sans 3", "Segoe UI", Arial, sans-serif !important;
  }
}
