/* ==================================================================
   Portal Alumni Malaysia — style.css
   Palet: biru laut dalam (institusi) + emas konvokesyen + hijau laut
   Tipografi: Fraunces (tajuk) / Public Sans (teks)
   ================================================================== */

:root {
  --ink:        #0E2A47;   /* biru laut dalam — warna utama */
  --ink-700:    #163A5F;
  --ink-500:    #2F5C86;
  --gold:       #C8A24A;   /* emas konvokesyen — aksen */
  --gold-soft:  #F2E6C8;
  --sea:        #1E6F6B;   /* hijau laut — tindakan kedua */
  --paper:      #F7F6F2;   /* latar halaman */
  --line:       #E1DED4;   /* garisan pemisah */
  --body:       #33383F;
  --muted:      #6C737F;

  --radius-sm: .5rem;
  --radius:    .875rem;
  --radius-lg: 1.25rem;
  --shadow:    0 1px 2px rgba(14,42,71,.06), 0 8px 24px -12px rgba(14,42,71,.18);
  --shadow-lg: 0 24px 60px -28px rgba(14,42,71,.45);

  --bs-primary: var(--ink);
  --bs-link-color: var(--ink-700);
  --bs-link-hover-color: var(--gold);
  --bs-body-color: var(--body);
  --bs-body-font-family: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ---------------------------- ASAS ---------------------------- */
body {
  font-family: var(--bs-body-font-family);
  color: var(--body);
  background: var(--paper);
  font-size: .95rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .font-display {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-optical-sizing: auto;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -.015em;
}
h1 { font-size: clamp(1.9rem, 1.2rem + 2.4vw, 3.1rem); line-height: 1.12; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.15rem); line-height: 1.2; }
h3 { font-size: 1.3rem; }

p { max-width: 72ch; }

a { text-decoration: none; transition: color .15s ease; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.text-ink   { color: var(--ink) !important; }
.text-gold  { color: var(--gold) !important; }
.text-sea   { color: var(--sea) !important; }
.bg-ink     { background-color: var(--ink) !important; }
.bg-paper   { background-color: var(--paper) !important; }
.bg-gold-soft { background-color: var(--gold-soft) !important; }

/* Aksen garis emas di bawah tajuk seksyen */
.section-title { position: relative; padding-bottom: .75rem; margin-bottom: .35rem; }
.section-title::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 3.25rem; height: 3px; background: var(--gold); border-radius: 2px;
}
.text-center .section-title::after { left: 50%; transform: translateX(-50%); }

/* --------------------------- BUTANG --------------------------- */
.btn { font-weight: 600; border-radius: var(--radius-sm); padding: .55rem 1.15rem; }
.btn-ink { background: var(--ink); color: #fff; border: 1px solid var(--ink); }
.btn-ink:hover, .btn-ink:focus { background: var(--ink-700); color: #fff; border-color: var(--ink-700); }
.btn-gold { background: var(--gold); color: #24201A; border: 1px solid var(--gold); }
.btn-gold:hover, .btn-gold:focus { background: #b8912f; color: #1a1710; border-color: #b8912f; }
.btn-outline-ink { color: var(--ink); border: 1px solid rgba(14,42,71,.3); background: transparent; }
.btn-outline-ink:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-sea { background: var(--sea); color: #fff; border: 1px solid var(--sea); }
.btn-sea:hover { background: #185955; color: #fff; }

/* --------------------------- TOPBAR --------------------------- */
.topbar {
  background: var(--ink);
  color: rgba(255,255,255,.82);
  font-size: .8rem;
  padding: .45rem 0;
}
.topbar a { color: rgba(255,255,255,.82); }
.topbar a:hover { color: var(--gold); }

/* --------------------------- NAVBAR --------------------------- */
.site-nav {
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(14,42,71,.04);
}
.site-nav .navbar-brand { display: flex; align-items: center; gap: .7rem; }
.site-nav .brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--ink); color: var(--gold); border-radius: 10px;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.05rem;
}
.site-nav .brand-text strong {
  display: block; font-family: 'Fraunces', serif; color: var(--ink);
  font-size: 1.02rem; line-height: 1.15;
}
.site-nav .brand-text span { font-size: .72rem; color: var(--muted); }
.site-nav .nav-link {
  color: var(--ink); font-weight: 500; font-size: .9rem;
  padding: .5rem .85rem !important; border-radius: 6px;
}
.site-nav .nav-link:hover { background: rgba(14,42,71,.05); }
.site-nav .nav-link.active { color: var(--ink); background: var(--gold-soft); }

/* ---------------------------- HERO ---------------------------- */
.hero {
  position: relative; color: #fff;
  background:
    linear-gradient(110deg, rgba(9,27,46,.96) 12%, rgba(14,42,71,.86) 58%, rgba(30,111,107,.72) 100%),
    url('../img/hero.svg') center/cover no-repeat, var(--ink);
}
.hero-inner { padding: clamp(3.5rem, 8vw, 7rem) 0; }
.hero h1 { color: #fff; max-width: 17ch; }
.hero .lead { color: rgba(255,255,255,.85); max-width: 52ch; font-size: 1.05rem; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  border: 1px solid rgba(255,255,255,.28); border-radius: 999px;
  padding: .3rem .85rem; font-size: .78rem; color: var(--gold-soft);
  margin-bottom: 1.1rem;
}
.hero-stats { border-top: 1px solid rgba(255,255,255,.16); margin-top: 2.5rem; padding-top: 1.5rem; }
.hero-stat .num {
  font-family: 'Fraunces', serif; font-size: 1.9rem; color: var(--gold); line-height: 1;
}
.hero-stat .lbl { font-size: .78rem; color: rgba(255,255,255,.7); }

/* Karusel hero */
.hero-carousel .carousel-item { min-height: 1px; }
.carousel-indicators [data-bs-target] { background-color: var(--gold); }

/* --------------------------- KAD ------------------------------ */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.card-soft { box-shadow: var(--shadow); border-color: transparent; }

.news-card { overflow: hidden; height: 100%; }
.news-card .thumb { aspect-ratio: 16/10; object-fit: cover; width: 100%; background: var(--gold-soft); }
.news-card .card-title { font-size: 1.05rem; }
.news-card .meta { font-size: .78rem; color: var(--muted); }

.feature-card { padding: 1.6rem; height: 100%; border-radius: var(--radius); }
.feature-card .ico {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--ink); font-size: 1.05rem; margin-bottom: 1rem;
}

/* Blok CTA portal (gaya portal ahli) */
.portal-block { background: var(--ink); color: #fff; border-radius: var(--radius-lg); }
.portal-block h2 { color: #fff; }
.portal-block ul { list-style: none; padding: 0; margin: 1.25rem 0 0; }
.portal-block li { display: flex; gap: .7rem; align-items: flex-start; padding: .4rem 0; color: rgba(255,255,255,.85); }
.portal-block li i { color: var(--gold); margin-top: .25rem; }

/* Item acara */
.event-row {
  display: flex; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line);
}
.event-date {
  flex: 0 0 62px; text-align: center; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff; padding: .5rem .25rem; align-self: flex-start;
}
.event-date .d { font-family: 'Fraunces', serif; font-size: 1.4rem; line-height: 1; }
.event-date .m { font-size: .7rem; text-transform: none; color: var(--gold-soft); }

/* Galeri */
.gallery-tile { position: relative; overflow: hidden; border-radius: var(--radius); background: #fff; }
.gallery-tile img { aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.gallery-tile .tag {
  position: absolute; top: .6rem; left: .6rem; background: rgba(14,42,71,.88); color: #fff;
  font-size: .7rem; padding: .18rem .55rem; border-radius: 6px;
}
.gallery-note { background: var(--gold-soft); padding: 1.25rem; border-radius: var(--radius); }

/* -------------------------- FOOTER ---------------------------- */
.site-footer { background: #0A1F35; color: rgba(255,255,255,.72); padding-top: 3.5rem; }
.site-footer h6 { color: #fff; font-family: 'Fraunces', serif; font-size: 1rem; margin-bottom: 1rem; }
.site-footer a { color: rgba(255,255,255,.72); }
.site-footer a:hover { color: var(--gold); }
.site-footer .footer-bottom {
  border-top: 1px solid rgba(255,255,255,.12); margin-top: 2.5rem; padding: 1.1rem 0; font-size: .82rem;
}
.social-dot {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
  background: rgba(255,255,255,.09); color: #fff;
}
.social-dot:hover { background: var(--gold); color: #1a1710; }

/* Butang WhatsApp terapung */
.wa-float {
  position: fixed; right: 18px; bottom: 18px; z-index: 1030;
  background: #25D366; color: #fff; border-radius: 999px;
  padding: .65rem 1.1rem; font-weight: 600; box-shadow: var(--shadow-lg);
  display: inline-flex; align-items: center; gap: .5rem;
}
.wa-float:hover { color: #fff; filter: brightness(.95); }

/* ==================================================================
   PAPAN PEMUKA (semua peranan)
   ================================================================== */
.dash-body { background: var(--paper); }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 1040;
  background: var(--ink); color: rgba(255,255,255,.75);
  display: flex; flex-direction: column; overflow-y: auto;
  transition: transform .25s ease;
}
.sidebar-head { padding: 1.15rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-head .brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--gold); color: var(--ink);
  display: grid; place-items: center; font-family: 'Fraunces', serif; font-weight: 700;
}
.sidebar-head strong { color: #fff; font-family: 'Fraunces', serif; font-size: .98rem; }
.sidebar-head small { color: var(--gold); font-size: .72rem; }

.sidebar .nav-section {
  font-size: .68rem; color: rgba(255,255,255,.4); padding: 1.1rem 1.35rem .35rem;
  letter-spacing: .04em;
}
.sidebar .nav-link {
  color: rgba(255,255,255,.75); padding: .58rem 1.35rem; display: flex; align-items: center;
  gap: .75rem; font-size: .88rem; border-left: 3px solid transparent;
}
.sidebar .nav-link i { width: 18px; text-align: center; font-size: .95rem; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active {
  background: rgba(200,162,74,.16); color: #fff; border-left-color: var(--gold);
}
.sidebar .nav-link .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 1rem 1.35rem; border-top: 1px solid rgba(255,255,255,.1); font-size: .78rem; }

.main-wrap { margin-left: 264px; min-height: 100vh; display: flex; flex-direction: column; }

.dash-header {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .7rem 1.5rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 1020;
}
.dash-header .page-title { font-family: 'Fraunces', serif; font-size: 1.12rem; margin: 0; color: var(--ink); }
.dash-header .role-chip {
  font-size: .72rem; background: var(--gold-soft); color: #6b5518;
  padding: .18rem .6rem; border-radius: 999px; border: 1px solid rgba(200,162,74,.4);
}
.dash-content { padding: 1.6rem; flex: 1; }
.dash-footer {
  border-top: 1px solid var(--line); background: #fff; padding: .9rem 1.5rem;
  font-size: .8rem; color: var(--muted);
}

.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; }
.avatar-fallback {
  display: grid; place-items: center; background: var(--gold-soft);
  color: var(--ink); font-weight: 700; font-family: 'Fraunces', serif;
}

/* Kad statistik */
.stat-card { padding: 1.15rem 1.25rem; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); }
.stat-card .ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 1rem; }
.stat-card .num { font-family: 'Fraunces', serif; font-size: 1.85rem; color: var(--ink); line-height: 1.05; }
.stat-card .lbl { font-size: .8rem; color: var(--muted); }

/* Jadual */
.table { --bs-table-bg: transparent; font-size: .88rem; }
.table > thead th {
  font-size: .74rem; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line); background: #FBFAF7; white-space: nowrap;
}
.table > tbody td { vertical-align: middle; border-color: var(--line); }
.table-hover > tbody > tr:hover > * { background: rgba(200,162,74,.07); }

/* Borang */
.form-label { font-weight: 600; font-size: .84rem; color: var(--ink); margin-bottom: .3rem; }
.form-control, .form-select {
  border-radius: var(--radius-sm); border-color: var(--line); font-size: .9rem; padding: .5rem .75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--ink-500); box-shadow: 0 0 0 .2rem rgba(47,92,134,.15);
}
.form-text { font-size: .78rem; }
.required::after { content: ' *'; color: #b02a37; }

/* Kalendar acara */
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; }
.calendar th {
  padding: .6rem; font-size: .74rem; color: var(--muted); text-align: center;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.calendar td {
  border: 1px solid var(--line); height: 110px; vertical-align: top; padding: .4rem; position: relative;
}
.calendar td.muted { background: #FBFAF7; color: #B9BCC2; }
.calendar td.today { background: var(--gold-soft); }
.calendar .daynum { font-size: .82rem; font-weight: 600; color: var(--ink); }
.calendar .ev {
  display: block; font-size: .72rem; color: #fff; background: var(--ink);
  border-radius: 4px; padding: .1rem .35rem; margin-top: .2rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.calendar .ev:hover { filter: brightness(1.15); color: #fff; }

/* Kad keahlian alumni */
.member-card {
  background: linear-gradient(135deg, var(--ink) 0%, #123252 55%, var(--sea) 140%);
  color: #fff; border-radius: var(--radius-lg); padding: 1.6rem; position: relative; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.member-card::after {
  content: ''; position: absolute; right: -50px; top: -50px; width: 190px; height: 190px;
  border: 26px solid rgba(200,162,74,.16); border-radius: 50%;
}
.member-card .mno {
  font-family: 'Fraunces', serif; font-size: 1.3rem; color: var(--gold); letter-spacing: .04em;
}
.member-card .lbl { font-size: .68rem; color: rgba(255,255,255,.6); }
.member-card .val { font-size: .88rem; color: #fff; }

/* Garis masa */
.timeline { list-style: none; padding-left: 1.2rem; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1.1rem 1.1rem; font-size: .86rem; }
.timeline li::before {
  content: ''; position: absolute; left: -1.42rem; top: .45rem; width: 9px; height: 9px;
  border-radius: 50%; background: var(--gold); border: 2px solid #fff;
}

/* Keadaan kosong */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.25rem; color: var(--line); margin-bottom: .85rem; display: block; }

/* Halaman pengesahan */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside {
  background: linear-gradient(155deg, var(--ink) 0%, #123252 60%, var(--sea) 130%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center;
}
.auth-aside h2 { color: #fff; }
.auth-aside ul { list-style: none; padding: 0; }
.auth-aside li { padding: .35rem 0; color: rgba(255,255,255,.82); display: flex; gap: .6rem; }
.auth-aside li i { color: var(--gold); margin-top: .3rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: #fff; }
.auth-box { width: 100%; max-width: 420px; }

/* Penunjuk kekuatan kata laluan */
.pw-meter { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: .45rem; }
.pw-meter span { display: block; height: 100%; width: 0; transition: width .25s ease, background .25s ease; }

/* Langkah pendaftaran */
.steps { display: flex; gap: .5rem; margin-bottom: 1.75rem; }
.step { flex: 1; padding-top: .55rem; border-top: 3px solid var(--line); font-size: .78rem; color: var(--muted); }
.step.active { border-top-color: var(--gold); color: var(--ink); font-weight: 600; }
.step.done { border-top-color: var(--sea); color: var(--sea); }

/* -------------------------- RESPONSIF ------------------------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-wrap { margin-left: 0; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
@media (max-width: 575.98px) {
  .dash-content { padding: 1rem; }
  .calendar td { height: 76px; font-size: .72rem; }
  .calendar .ev { font-size: .62rem; }
}

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(10,31,53,.5); z-index: 1035; display: none;
}
.sidebar-backdrop.show { display: block; }

/* Kurangkan gerakan */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Cetak — kad keahlian & laporan */
@media print {
  .sidebar, .dash-header, .dash-footer, .site-footer, .site-nav, .topbar, .wa-float, .no-print { display: none !important; }
  .main-wrap { margin-left: 0; }
  body { background: #fff; }
}

/* ================================================================
   MIKROLAMAN INSTITUSI (halaman khusus setiap institusi)
   ================================================================ */
.inst-banner {
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-700, #0A1F35) 100%);
  color: #fff;
}
.inst-banner-logo {
  width: 76px; height: 76px; object-fit: contain;
  background: #fff; border-radius: 18px; padding: 8px; flex: 0 0 auto;
}
.inst-banner-kicker {
  display: inline-block; font-size: .72rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--gold);
  border: 1px solid rgba(200,162,74,.45); border-radius: 999px;
  padding: .15rem .7rem; margin-bottom: .5rem;
}
.inst-banner-name {
  font-family: 'Fraunces', serif; color: #fff;
  font-size: clamp(1.35rem, 3vw, 2rem); margin: 0 0 .35rem;
}
.inst-banner-meta { font-size: .84rem; color: rgba(255,255,255,.75); }
.inst-banner-meta a { color: var(--gold); }
.inst-banner-back { font-size: .8rem; color: rgba(255,255,255,.7); }
.inst-banner-back:hover { color: var(--gold); }

.inst-subnav {
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1020;
}
.inst-subnav .nav { flex-wrap: nowrap; overflow-x: auto; gap: .25rem; }
.inst-subnav .nav::-webkit-scrollbar { height: 0; }
.inst-subnav .nav-link {
  white-space: nowrap; font-weight: 600; font-size: .88rem;
  color: var(--muted); padding: .85rem 1rem;
  border-bottom: 3px solid transparent; border-radius: 0;
}
.inst-subnav .nav-link:hover { color: var(--ink); }
.inst-subnav .nav-link.active { color: var(--ink); border-bottom-color: var(--gold); }

/* Kad institusi pada senarai / halaman utama */
.inst-card { height: 100%; display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; }
.inst-card .inst-card-head {
  display: flex; gap: .85rem; align-items: center;
  padding: 1.1rem 1.15rem .75rem;
}
.inst-card .inst-card-logo {
  width: 48px; height: 48px; object-fit: contain;
  background: var(--gold-soft); border-radius: 12px; flex: 0 0 auto;
}
.inst-card .inst-card-links {
  display: flex; gap: .35rem; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding: .6rem .75rem;
  background: #FBFAF7;
}
.inst-card .inst-card-links a {
  font-size: .74rem; font-weight: 600; color: var(--ink);
  padding: .3rem .6rem; border-radius: 999px; background: #fff;
  border: 1px solid var(--line);
}
.inst-card .inst-card-links a:hover { background: var(--gold-soft); border-color: var(--gold); }

@media (max-width: 575.98px) {
  .inst-banner-logo { width: 58px; height: 58px; }
  .inst-subnav .nav-link { padding: .7rem .75rem; font-size: .82rem; }
}

/* ==================================================================
   LAPISAN MUDAH ALIH DAHULU (MOBILE-FIRST)
   Ditulis selepas semua peraturan asas supaya ia menjadi rujukan akhir.
   Strategi: reka bentuk asas = telefon; ditingkatkan ke atas dengan
   pertanyaan `min-width`. Diuji pada 360px, 768px, 1024px dan 1440px.
   ================================================================== */

:root {
  --dash-header-h:  56px;
  --bottom-nav-h:   62px;
  --sidebar-w:      264px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
  --tap:         44px;   /* saiz sasaran sentuh minimum */
}

/* ------------------------- ASAS PERANTI ------------------------ */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--dash-header-h) + 12px);
}
body {
  overflow-x: hidden;
  overscroll-behavior-y: none;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
table { max-width: 100%; }

/* Elak teks panjang memecahkan susun atur pada skrin sempit */
h1, h2, h3, h4, h5, h6, p, a, td, th, li, .card-title { overflow-wrap: anywhere; }
p { max-width: 72ch; }

/* Kunci tatal badan semasa laci menu dibuka */
body.nav-open { overflow: hidden; touch-action: none; }

/* ------------------ SASARAN SENTUH & BORANG ------------------- */
@media (pointer: coarse) {
  .btn, .nav-link, .dropdown-item, .page-link,
  .form-check-input, .navbar-toggler, .btn-close {
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
  }
  .btn-sm { min-height: 38px; }
  .dropdown-item, .page-link { display: flex; }
  .btn-group-sm > .btn { min-height: 38px; padding-inline: .7rem; }
  .form-check-input { min-width: 1.15rem; }
}

/* iOS membesarkan halaman jika saiz teks input < 16px — elakkannya */
@media (max-width: 767.98px) {
  .form-control, .form-select, textarea, input[type="search"] {
    font-size: 16px;
    padding: .65rem .8rem;
  }
  .form-control-sm, .form-select-sm { font-size: 16px; padding: .5rem .7rem; }
  .form-label { font-size: .86rem; }
}

/* Susunan borang bertindan pada telefon, sebaris pada tablet ke atas */
@media (max-width: 575.98px) {
  .row > [class*="col-"] { margin-bottom: 0; }
  .btn-toolbar, .d-flex.gap-2.flex-wrap > form { width: auto; }
  form .d-grid > .btn { width: 100%; }
}

/* ------------------------ RUANG & TAIP ------------------------ */
.container, .container-fluid { padding-inline: 1rem; }
@media (min-width: 768px) { .container, .container-fluid { padding-inline: 1.5rem; } }

@media (max-width: 575.98px) {
  section.py-5 { padding-top: 2.25rem !important; padding-bottom: 2.25rem !important; }
  .section-title { padding-bottom: .55rem; margin-bottom: .5rem; }
  .card-soft, .card { border-radius: var(--radius); }
  .p-4, .p-lg-5 { padding: 1.1rem !important; }
  .card.p-4 { padding: 1.1rem !important; }
}

/* ------------------------- LAMAN AWAM ------------------------- */
/* Bar atas: gulung mendatar pada telefon dan bukannya membalut tinggi */
@media (max-width: 991.98px) {
  .topbar { font-size: .74rem; }
  .topbar .container { flex-wrap: nowrap; overflow-x: auto; gap: 1rem; }
  .topbar .container::-webkit-scrollbar { display: none; }
  .topbar .d-flex { flex-wrap: nowrap; white-space: nowrap; }
}
@media (max-width: 575.98px) {
  .topbar .container > div:first-child span:first-child { display: none; } /* alamat penuh terlalu panjang */
}

.site-nav .navbar-brand .brand-text span { display: none; }
@media (min-width: 992px) { .site-nav .navbar-brand .brand-text span { display: block; } }

@media (max-width: 991.98px) {
  .site-nav .navbar-collapse {
    max-height: calc(100vh - 120px); overflow-y: auto;
    margin-top: .75rem; padding-bottom: .75rem;
    border-top: 1px solid var(--line);
  }
  .site-nav .nav-link { padding: .75rem .35rem; border-bottom: 1px solid rgba(0,0,0,.04); }
  .site-nav .navbar-collapse .btn { width: 100%; justify-content: center; }
  .site-nav .navbar-collapse .d-flex { flex-direction: column; }
}

/* Hero — ketinggian lebih pendek dan teks lebih rapat pada telefon */
.hero-inner { padding: clamp(2.25rem, 9vw, 7rem) 0; }
.hero h1 { max-width: 20ch; }
@media (max-width: 575.98px) {
  .hero .lead { font-size: .95rem; }
  .hero-stats { margin-top: 1.75rem; padding-top: 1.1rem; }
  .hero-stat .num { font-size: 1.5rem; }
  .hero .d-flex.flex-wrap.gap-2 .btn { flex: 1 1 100%; justify-content: center; }
  .hero .btn-lg { padding: .7rem 1rem; font-size: .95rem; }
}

/* Kad berita / galeri — gambar lebih pendek pada telefon */
@media (max-width: 575.98px) {
  .news-card .thumb { aspect-ratio: 16/9; }
  .gallery-tile img { aspect-ratio: 16/10; }
  .event-row { padding: .85rem; }
  .event-date { min-width: 54px; }
}

/* Butang WhatsApp terapung — jangan bertindih dengan bar bawah */
.wa-float {
  bottom: calc(1rem + var(--safe-bottom));
  right: calc(1rem + var(--safe-right));
  width: 52px; height: 52px;
}
@media (max-width: 991.98px) {
  body.has-bottom-nav .wa-float { bottom: calc(var(--bottom-nav-h) + .75rem + var(--safe-bottom)); }
}

/* Pengaki laman */
@media (max-width: 575.98px) {
  .site-footer { padding-top: 2.25rem; text-align: left; }
  .site-footer .footer-bottom { flex-direction: column; gap: .5rem; text-align: center; }
}

/* --------------------- MIKROLAMAN INSTITUSI -------------------- */
@media (max-width: 767.98px) {
  .inst-banner .d-flex { gap: .85rem !important; }
  .inst-banner .text-lg-end { width: 100%; }
  .inst-banner .text-lg-end .btn { width: 100%; justify-content: center; }
}
.inst-subnav { top: var(--nav-h, 0px); }
.inst-subnav .nav { scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.inst-subnav .nav-item { scroll-snap-align: start; }
.inst-subnav::after {   /* petunjuk bahawa menu boleh digulung */
  content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 28px;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff 70%);
  pointer-events: none;
}
@media (min-width: 992px) { .inst-subnav::after { display: none; } }
.inst-subnav { position: sticky; top: var(--nav-h, 0px); }

/* ===================== PAPAN PEMUKA MUDAH ALIH ================== */

/* Laci menu sisi */
@media (max-width: 991.98px) {
  .sidebar {
    width: min(82vw, 300px);
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  .sidebar .nav-link { padding: .8rem 1.25rem; font-size: .92rem; }
  .main-wrap { margin-left: 0; }
}
@media (min-width: 992px) {
  .sidebar { transform: none !important; }
  .sidebar-backdrop { display: none !important; }
  .main-wrap { margin-left: var(--sidebar-w); }
}

/* Pengepala papan pemuka */
.dash-header {
  padding: .55rem 1rem;
  padding-top: calc(.55rem + var(--safe-top));
  gap: .55rem;
  min-height: var(--dash-header-h);
  transition: box-shadow .2s ease;
}
.dash-header.is-scrolled { box-shadow: 0 6px 18px -12px rgba(14,42,71,.5); }
.dash-header .page-title { font-size: 1rem; }
@media (max-width: 575.98px) {
  .dash-header .role-chip { display: none; }
  .dash-header .dropdown-menu { width: min(92vw, 320px) !important; }
}
@media (min-width: 768px) {
  .dash-header { padding: .7rem 1.5rem; gap: 1rem; }
  .dash-header .page-title { font-size: 1.12rem; }
}

.dash-content { padding: 1rem; }
@media (min-width: 768px)  { .dash-content { padding: 1.35rem; } }
@media (min-width: 1200px) { .dash-content { padding: 1.6rem; } }

.dash-footer { padding: .9rem 1rem; font-size: .76rem; }
@media (max-width: 767.98px) { .dash-footer { flex-direction: column; gap: .3rem; } }

/* Bar navigasi bawah (hanya telefon & tablet kecil) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -6px 20px -14px rgba(14,42,71,.55);
}
.bottom-nav a {
  flex: 1 1 0; min-width: 0; text-align: center;
  padding: .5rem .25rem; color: var(--muted);
  font-size: .66rem; font-weight: 600; line-height: 1.25;
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  min-height: var(--bottom-nav-h);
  justify-content: center;
}
.bottom-nav a i { font-size: 1.05rem; }
.bottom-nav a span { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav a.active { color: var(--ink); }
.bottom-nav a.active i { color: var(--gold); }
.bottom-nav a:active { background: var(--gold-soft); }

body.has-bottom-nav .main-wrap { padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom)); }
@media (min-width: 992px) {
  .bottom-nav { display: none; }
  body.has-bottom-nav .main-wrap { padding-bottom: 0; }
}

/* Kad statistik lebih padat pada telefon */
@media (max-width: 575.98px) {
  .stat-card { padding: .85rem .9rem; }
  .stat-card .ico { width: 34px; height: 34px; font-size: .85rem; border-radius: 9px; }
  .stat-card .num { font-size: 1.4rem; }
  .stat-card .lbl { font-size: .72rem; line-height: 1.3; }
}

/* ------------------------ JADUAL RESPONSIF --------------------- */
.table-responsive { -webkit-overflow-scrolling: touch; }

/*
  Pada telefon, setiap baris jadual dipaparkan sebagai kad.
  Label lajur disuntik oleh app.js sebagai atribut data-label,
  jadi tiada perubahan diperlukan pada mana-mana fail PHP.
*/
@media (max-width: 767.98px) {
  .table-responsive > .table.table-stack { font-size: .86rem; }
  .table.table-stack, .table.table-stack tbody, .table.table-stack tr, .table.table-stack td { display: block; width: 100%; }
  .table.table-stack thead { display: none; }
  .table.table-stack > tbody > tr {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: .75rem; padding: .35rem .15rem; box-shadow: var(--shadow);
  }
  .table.table-stack > tbody > tr > td {
    border: 0; border-bottom: 1px dashed var(--line);
    display: flex; gap: .75rem; align-items: center; justify-content: space-between;
    padding: .5rem .85rem; text-align: right;
  }
  .table.table-stack > tbody > tr > td:last-child { border-bottom: 0; }
  .table.table-stack > tbody > tr > td::before {
    content: attr(data-label);
    flex: 0 0 38%; text-align: left;
    font-size: .7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .03em; color: var(--muted);
  }
  .table.table-stack > tbody > tr > td:empty { display: none; }
  .table.table-stack > tbody > tr > td[data-label=""] { justify-content: flex-end; }
  .table.table-stack .btn-group { flex-wrap: wrap; justify-content: flex-end; gap: .25rem; }
  .table.table-stack .btn-group > .btn,
  .table.table-stack .btn-group > form > .btn { border-radius: var(--radius-sm) !important; }
  .table-hover.table-stack > tbody > tr:hover > * { background: transparent; }
}

/* ------------------------- KALENDAR ---------------------------- */
.calendar-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
  .calendar { min-width: 560px; }   /* gulung mendatar, kekalkan bentuk grid */
  .calendar td { height: 84px; }
  .calendar .ev { font-size: .6rem; padding: .1rem .25rem; }
  .calendar .daynum { font-size: .75rem; }
}
@media (max-width: 575.98px) {
  .calendar { min-width: 520px; }
}

/* ------------------------ KAD KEAHLIAN ------------------------- */
@media (max-width: 575.98px) {
  .member-card { padding: 1.15rem; }
  .member-card .mno { font-size: 1.1rem; letter-spacing: .04em; word-break: break-all; }
}

/* --------------------- HALAMAN PENGESAHAN ---------------------- */
@media (max-width: 991.98px) {
  .auth-shell { min-height: 100svh; }
  .auth-main { padding: 1.75rem 1.15rem calc(2rem + var(--safe-bottom)); }
}

/* ------------------------- LANGKAH-LANGKAH ---------------------- */
@media (max-width: 575.98px) {
  .steps { gap: .3rem; margin-bottom: 1.15rem; }
  .step { font-size: .68rem; }
}

/* ------------------------- KEMBALI KE ATAS ---------------------- */
.to-top {
  position: fixed; z-index: 1025;
  right: calc(1rem + var(--safe-right));
  bottom: calc(4.75rem + var(--safe-bottom));
  width: 42px; height: 42px; border-radius: 50%;
  display: none; place-items: center;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.to-top.show { display: grid; }
@media (min-width: 992px) { .to-top { bottom: calc(5.5rem + var(--safe-bottom)); } }

/* ----------------------- PEMBANTU PAPARAN ----------------------- */
.only-mobile  { display: block; }
.only-desktop { display: none; }
@media (min-width: 992px) {
  .only-mobile  { display: none; }
  .only-desktop { display: block; }
}
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }

/* ------------------------- CETAK (kemas) ------------------------ */
@media print {
  .bottom-nav, .to-top, .inst-subnav, .inst-banner .btn, .breadcrumb { display: none !important; }
  body.has-bottom-nav .main-wrap { padding-bottom: 0; }
  .table.table-stack, .table.table-stack tbody, .table.table-stack tr, .table.table-stack td { display: revert; }
  .table.table-stack thead { display: table-header-group; }
  .table.table-stack td::before { content: none; }
}

/* ==================================================================
   KELAS UTILITI YANG HILANG / KANDUNGAN ARTIKEL
   ================================================================== */
.min-width-0 { min-width: 0; }

/* Badan artikel (berita, dasar, terma) — mudah dibaca pada telefon */
.article-body { font-size: 1rem; line-height: 1.75; color: var(--body); }
.article-body > * + * { margin-top: 1rem; }
.article-body p { max-width: 68ch; }
.article-body h2 { font-size: 1.25rem; margin-top: 2rem; }
.article-body h3 { font-size: 1.08rem; margin-top: 1.5rem; }
.article-body ul, .article-body ol { padding-left: 1.25rem; }
.article-body li { margin-bottom: .4rem; }
.article-body img { border-radius: var(--radius); margin-block: 1.25rem; }
.article-body blockquote {
  border-left: 3px solid var(--gold); padding: .35rem 0 .35rem 1rem;
  color: var(--muted); font-style: italic; margin-inline: 0;
}
.article-body a { color: var(--ink-700); text-decoration: underline; text-underline-offset: 3px; }
.article-body table { width: 100%; font-size: .88rem; border-collapse: collapse; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: .5rem .65rem; }
@media (max-width: 575.98px) {
  .article-body { font-size: .96rem; }
  .article-body h2 { font-size: 1.15rem; }
}

/* Roti pemanggang (breadcrumb) — muat pada satu baris di telefon */
.breadcrumb { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--muted); }

/* Butang garis putih (digunakan dalam blok portal berlatar gelap) */
.btn-outline-light { border-color: rgba(255,255,255,.5); color: #fff; }
.btn-outline-light:hover { background: #fff; color: var(--ink); border-color: #fff; }

/* ==================================================================
   BAR PENAPIS — batalkan lebar tetap sebaris pada skrin kecil
   Beberapa paparan modul menetapkan style="width:250px" dan seumpamanya
   supaya penapis kelihatan kemas pada desktop. Pada telefon lebar tetap
   itu menyebabkan limpahan mendatar, jadi ia dibatalkan di sini.
   ================================================================== */
@media (max-width: 767.98px) {
  form.d-flex .form-control,
  form.d-flex .form-select,
  form.d-flex input[type="search"],
  .dash-content form .form-control[style],
  .dash-content form .form-select[style] {
    width: 100% !important;
    min-width: 0;
    flex: 1 1 100%;
  }
  .dash-content form.d-flex { flex-direction: column; align-items: stretch; }
  .dash-content form.d-flex .btn { width: 100%; justify-content: center; }

  /* Baris "penapis + tindakan" menjadi bertindan penuh */
  .dash-content .d-flex.flex-wrap.justify-content-between > form,
  .dash-content .d-flex.flex-wrap.justify-content-between > .d-flex { width: 100%; }
  .dash-content .d-flex.flex-wrap.justify-content-between > .d-flex .btn { flex: 1 1 auto; justify-content: center; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  form.d-flex .form-control[style],
  form.d-flex .form-select[style] { max-width: 100%; }
}

/* ==================================================================
   PENYUNTING WYSIWYG (Summernote) — diselaraskan dengan sistem reka bentuk
   ================================================================== */
.note-editor.note-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  margin-bottom: 0;
  box-shadow: none;
  font-family: var(--bs-body-font-family);
}
.note-editor.note-frame.codeview { background: #FBFAF7; }

.note-toolbar {
  background: #FBFAF7 !important;
  border-bottom: 1px solid var(--line) !important;
  padding: .4rem .5rem !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.note-toolbar .note-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--body);
  border-radius: 6px;
  padding: .3rem .55rem;
  font-size: .82rem;
}
.note-toolbar .note-btn:hover  { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.note-toolbar .note-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.note-toolbar .note-btn-group { margin-right: .3rem; margin-bottom: .2rem; }

.note-editable {
  padding: 1rem 1.1rem !important;
  font-size: .95rem;
  line-height: 1.7;
  color: var(--body);
}
.note-editable:focus { outline: none; }
.note-editor.note-frame:focus-within {
  border-color: var(--ink-500);
  box-shadow: 0 0 0 .2rem rgba(47,92,134,.15);
}
.note-placeholder { color: var(--muted); padding: 1rem 1.1rem !important; }

/* Sepadankan pratonton dalam penyunting dengan gaya laman awam */
.note-editable h2 { font-size: 1.3rem; }
.note-editable h3 { font-size: 1.12rem; }
.note-editable h4 { font-size: 1rem; }
.note-editable blockquote {
  border-left: 3px solid var(--gold);
  padding: .3rem 0 .3rem 1rem;
  color: var(--muted);
  margin-inline: 0;
}
.note-editable pre {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .75rem; font-size: .85rem;
}
.note-editable img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.note-editable table { width: 100%; border-collapse: collapse; }
.note-editable th, .note-editable td { border: 1px solid var(--line); padding: .45rem .6rem; }

.note-statusbar { background: #FBFAF7; border-top: 1px solid var(--line); }
.note-status-output { padding: 0 .6rem; font-size: .78rem; color: var(--muted); }

/* Dialog (pautan, imej, video) */
.note-modal .modal-content { border-radius: var(--radius); border: 1px solid var(--line); }
.note-modal .note-form-label { font-weight: 600; font-size: .84rem; color: var(--ink); }
.note-modal .note-btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.note-modal .note-btn-primary:hover { background: var(--ink-700); border-color: var(--ink-700); }

/* Skrin penuh — jangan tersembunyi di bawah pengepala melekat */
.note-editor.note-frame.fullscreen { z-index: 1060; }

/* Mudah alih: bar alat digulung mendatar dan bukannya membalut tinggi */
@media (max-width: 767.98px) {
  .note-toolbar {
    display: flex; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .note-toolbar::-webkit-scrollbar { display: none; }
  .note-toolbar .note-btn-group { flex: 0 0 auto; margin-bottom: 0; }
  .note-toolbar .note-btn { min-height: 38px; padding: .35rem .5rem; }
  .note-editable { padding: .85rem !important; font-size: 16px; }  /* elak zum iOS */
  .note-modal .modal-dialog { margin: .5rem; }
}
