:root {
  --navy: #001848;
  --navy-2: #003060;
  --navy-3: #184878;
  --gold: #d4b45a;
  --gold-soft: #f0e2b0;
  --red: #c62828;
  --sky: #e8f1f8;
  --mist: #f3f6fa;
  --ink: #152033;
  --muted: #5c6b7f;
  --line: #d5e0ec;
  --white: #ffffff;
  --danger: #b42318;
  --success: #067647;
  --warn: #b54708;
  --shadow: 0 18px 40px rgba(0, 24, 72, 0.1);
  --radius: 16px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1000px 420px at 8% -8%, rgba(212, 180, 90, 0.16), transparent 55%),
    radial-gradient(800px 380px at 100% 0%, rgba(0, 48, 96, 0.1), transparent 50%),
    linear-gradient(180deg, #f7fafc 0%, var(--mist) 100%);
  min-height: 100vh;
}

a { color: var(--navy-2); text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
img { max-width: 100%; display: block; }

.app-shell {
  display: grid;
  grid-template-columns: 288px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  background:
    linear-gradient(165deg, rgba(0, 18, 52, .97) 0%, rgba(0, 40, 82, .94) 55%, rgba(10, 28, 58, .96) 100%);
  color: #edf3f8;
  padding: 1.15rem .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(212, 180, 90, .18);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
  z-index: 40;
}
.sidebar::before {
  content: "";
  position: absolute; inset: 0 auto auto 0;
  width: 100%; height: 140px;
  background: radial-gradient(circle at 20% 0%, rgba(212,180,90,.22), transparent 62%);
  pointer-events: none;
}

.brand {
  position: relative;
  display: flex; gap: .8rem; align-items: center;
  padding: .55rem .55rem .95rem;
  margin: 0 .15rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  width: 48px; height: 48px; border-radius: 14px;
  object-fit: cover; background: #fff;
  box-shadow: 0 0 0 2px rgba(212,180,90,.7), 0 8px 18px rgba(0,0,0,.25);
  flex-shrink: 0;
}
.brand strong {
  display: block; font-family: var(--font-display);
  font-size: 1.12rem; line-height: 1.15; letter-spacing: -.02em;
}
.brand span { display: block; font-size: .72rem; opacity: .7; margin-top: .2rem; letter-spacing: .02em; }

.nav {
  position: relative;
  display: flex; flex-direction: column; gap: .18rem;
  flex: 1; overflow-y: auto; padding: .15rem .2rem .4rem;
  scrollbar-width: thin; scrollbar-color: rgba(212,180,90,.35) transparent;
}
.nav-label {
  margin: .85rem .55rem .28rem;
  font-size: .65rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: rgba(240, 226, 176, .55);
}
.nav-label:first-child { margin-top: .2rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem;
  color: rgba(231, 239, 248, .82);
  padding: .62rem .75rem;
  border-radius: 12px; font-weight: 600; font-size: .9rem;
  border: 1px solid transparent;
  transition: background .18s ease, color .18s ease, transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.nav-ico {
  width: 18px; height: 18px; flex-shrink: 0; opacity: .85;
}
.nav a:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  transform: translateX(2px);
}
.nav a.active {
  background: linear-gradient(135deg, rgba(212,180,90,.28), rgba(212,180,90,.1));
  color: var(--gold-soft);
  border-color: rgba(212,180,90,.35);
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
}
.nav a.active .nav-ico { opacity: 1; }

.sidebar-foot {
  position: relative;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .9rem .35rem 0;
  display: grid; gap: .7rem;
}
.user-chip {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .55rem;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
}
.user-avatar {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold), #a8843a);
  color: var(--navy); font-weight: 800; font-size: .78rem; letter-spacing: .02em;
}
.user-chip strong { display: block; font-size: .86rem; line-height: 1.2; }
.user-chip span { font-size: .72rem; opacity: .65; }
.btn-logout {
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  color: #edf3f8; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  border-radius: 12px; padding: .58rem .8rem; font-weight: 600; font-size: .86rem;
  transition: background .18s ease, border-color .18s ease;
}
.btn-logout:hover { background: rgba(196, 40, 40, .22); border-color: rgba(255,180,180,.35); color: #fff; }
.btn-logout .nav-ico { width: 16px; height: 16px; }

.main { padding: 1.2rem 1.75rem 2.5rem; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1.2rem;
  padding: .85rem 1rem;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(213, 224, 236, .9);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 24, 72, .05);
}
.topbar-left { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.eyebrow { color: var(--muted); font-size: .8rem; margin-bottom: .15rem; }
.topbar h1 { font-size: 1.55rem; color: var(--navy); }
.topbar-meta {
  display: flex; align-items: center; gap: .65rem; flex-wrap: wrap;
}
.year-pill {
  display: inline-block; background: var(--navy);
  padding: .42rem .8rem; border-radius: 999px;
  color: var(--gold-soft); font-size: .8rem; font-weight: 700;
}
.topbar-logos { display: flex; gap: .35rem; align-items: center; }
.topbar-logos img {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: #fff; border: 2px solid var(--gold-soft);
}
.menu-toggle {
  display: none;
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
  flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  cursor: pointer; flex-shrink: 0;
}
.menu-toggle span {
  display: block; width: 16px; height: 2px; background: var(--navy); border-radius: 2px;
}
.sidebar-backdrop {
  display: none;
}

.hero-banner {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  min-height: 210px;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  animation: rise .5s ease both;
}
.hero-banner img.hero-bg {
  width: 100%; height: 100%; min-height: 210px; object-fit: cover;
  position: absolute; inset: 0;
}
.hero-banner::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(0,24,72,.88) 0%, rgba(0,48,96,.55) 55%, rgba(0,24,72,.25) 100%);
}
.hero-content {
  position: relative; z-index: 1;
  color: #fff; padding: 1.6rem 1.7rem;
  display: grid; gap: .55rem; max-width: 640px;
}
.hero-content .kicker {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .8rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--gold-soft); font-weight: 700;
}
.hero-content h2 {
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  line-height: 1.15; color: #fff;
}
.hero-content p { color: rgba(255,255,255,.88); line-height: 1.5; max-width: 52ch; }
.hero-badges { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.hero-badges span {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  padding: .35rem .7rem; border-radius: 999px; font-size: .78rem;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  animation: rise .45s ease both;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--gold), var(--navy-2));
}
.stat:nth-child(2) { animation-delay: .05s; }
.stat:nth-child(3) { animation-delay: .1s; }
.stat:nth-child(4) { animation-delay: .15s; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { display: block; margin-top: .35rem; font-size: 1.7rem; font-family: var(--font-display); color: var(--navy); }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
  margin-bottom: 1.25rem;
  animation: rise .5s ease both;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.panel-head h2 { font-size: 1.2rem; color: var(--navy); }
.panel-sub { color: var(--muted); font-size: .9rem; margin-top: .2rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { padding: .75rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: #f8fbfd; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .28rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.badge-i { background: #e8f5ee; color: #067647; }
.badge-ii { background: #fff4e5; color: #b54708; }
.badge-iii { background: #fde8e6; color: #b42318; }
.badge-iv { background: #2b0b0b; color: #ffd7d2; }
.badge-muted { background: #eef2f6; color: #475467; }
.badge-ok { background: #e8f5ee; color: #067647; }
.badge-warn { background: #fff4e5; color: #b54708; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: 12px; padding: .65rem 1rem; font-weight: 600;
  cursor: pointer; font-family: inherit; font-size: .92rem;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 8px 18px rgba(0,24,72,.18); }
.btn-primary:hover { background: var(--navy-2); }
.btn-gold { background: linear-gradient(135deg, var(--gold), #b8963a); color: var(--navy); }
.btn-ghost { background: transparent; color: #edf3f8; border: 1px solid rgba(255,255,255,.2); }
.btn-outline { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; border-radius: 10px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: .35rem; font-size: .9rem; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .8rem; font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(212,180,90,.4); border-color: var(--gold);
}
textarea { min-height: 100px; resize: vertical; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }

.alert {
  padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500;
}
.alert-success { background: #e8f5ee; color: var(--success); border: 1px solid #abefc6; }
.alert-error { background: #fde8e6; color: var(--danger); border: 1px solid #fecdca; }
.alert-info { background: #eef4ff; color: var(--navy-2); border: 1px solid #c7d7fe; }
.alert-warning { background: #fff4e5; color: var(--warn); border: 1px solid #fedf89; }

.update-icon-row { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1rem; }
.update-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center;
  background: #e0f2fe; color: #0369a1; font-weight: 800; font-size: .85rem;
}
.update-list { color: var(--muted); font-size: .9rem; line-height: 1.7; margin: 0 0 1.1rem; padding-left: 1.15rem; }
.update-list code, .panel code, .alert code {
  font-size: .82em; background: #eef2f6; padding: .1rem .35rem; border-radius: 6px;
}
.update-hr { border: 0; border-top: 1px solid var(--line); margin: 1.4rem 0 1rem; }
.update-log {
  margin: 0; max-height: 280px; overflow: auto;
  background: #0f172a; color: #e2e8f0;
  border-radius: 12px; padding: 1rem; font-size: .82rem; line-height: 1.5;
}

.list-cards { display: grid; gap: .8rem; }
.list-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 1rem;
  background: linear-gradient(180deg, #fff, #fbfdff);
}
.list-card h3 { font-size: 1rem; margin-bottom: .35rem; color: var(--navy); }
.list-card p { color: var(--muted); white-space: pre-line; line-height: 1.55; }
.meta-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }

.two-col { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1.25rem; }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.filters label { min-width: 160px; }

.school-card {
  display: grid; gap: .9rem;
}
.school-card .cover-thumb {
  border-radius: 14px; overflow: hidden; border: 1px solid var(--line);
  aspect-ratio: 3/4; max-height: 280px;
}
.school-card .cover-thumb img { width: 100%; height: 100%; object-fit: cover; }
.jmj-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem;
}
.jmj-grid span {
  background: var(--sky); color: var(--navy-2); border-radius: 10px;
  padding: .45rem .5rem; font-size: .78rem; font-weight: 600; text-align: center;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
}
.gallery-item {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: #fff;
}
.gallery-item img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.gallery-item figcaption {
  padding: .65rem .75rem; font-size: .82rem; color: var(--muted); font-weight: 600;
}

.book-hero {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1.25rem;
  align-items: center;
}
.book-hero .cover {
  border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.book-hero .cover img { width: 100%; display: block; }
.book-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }

/* ===== Login ===== */
.auth-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  padding: 0;
  background: var(--navy);
}
.login-visual {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2rem;
  color: #fff;
}
.login-visual img.cover-full {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
}
.login-visual::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(0,24,72,.25) 0%, rgba(0,24,72,.55) 45%, rgba(0,24,72,.92) 100%),
    linear-gradient(90deg, rgba(0,24,72,.15), transparent 40%);
}
.login-visual-content {
  position: relative; z-index: 1;
  animation: rise .6s ease both;
}
.login-visual-content .logos {
  display: flex; gap: .7rem; margin-bottom: 1rem;
}
.login-visual-content .logos img {
  width: 68px; height: 68px; border-radius: 50%;
  background: #fff; object-fit: cover;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.login-visual-content h2 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  color: #fff; margin-bottom: .45rem;
}
.login-visual-content p {
  color: rgba(255,255,255,.88); max-width: 38ch; line-height: 1.5;
}
.login-visual-content .contact {
  margin-top: 1.1rem; display: flex; gap: 1rem; flex-wrap: wrap;
  font-size: .85rem; color: var(--gold-soft);
}
.login-panel {
  display: grid; place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(160deg, #f8fafc 0%, #eef3f8 100%);
  position: relative;
}
.login-panel::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 8px;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy) 55%, var(--gold) 55%, var(--gold) 100%);
}
.login-card {
  width: min(420px, 100%);
  background: rgba(255,255,255,.97);
  border-radius: 22px;
  padding: 2rem 1.75rem;
  box-shadow: 0 24px 60px rgba(0,24,72,.12);
  border: 1px solid var(--line);
  animation: rise .55s ease both;
}
.login-card .brand-login {
  display: flex; gap: .9rem; align-items: center; margin-bottom: 1.2rem;
}
.login-card .brand-login img {
  width: 58px; height: 58px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--gold-soft); background: #fff;
}
.login-card h1 { font-size: 1.55rem; color: var(--navy); margin-bottom: .35rem; }
.login-card .lead { color: var(--muted); margin-bottom: 1.4rem; line-height: 1.5; }
.login-card .form-grid { grid-template-columns: 1fr; }
.hint {
  margin-top: 1rem; padding: .8rem; border-radius: 12px;
  background: var(--sky); color: var(--navy-2); font-size: .85rem; line-height: 1.45;
}

.app-footer {
  margin-top: 1rem;
  padding: 1rem 0 .25rem;
  color: var(--muted);
  font-size: .82rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-top: 1px solid var(--line);
}

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .menu-toggle { display: flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; width: min(300px, 86vw);
    transform: translateX(-105%);
    transition: transform .28s ease;
    box-shadow: 24px 0 60px rgba(0,0,0,.28);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(8, 16, 32, .45);
  }
  .sidebar-backdrop[hidden] { display: none; }
  .grid-stats, .two-col, .form-grid, .book-hero { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jmj-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-body { grid-template-columns: 1fr; }
  .login-visual { min-height: 280px; }
}
