:root {
  --maroon: #7a1f1f;
  --maroon-dark: #5a1515;
  --gold: #c9962b;
  --gold-soft: #f6ecd2;
  --ink: #2a2321;
  --muted: #6f655f;
  --line: #e6dfd6;
  --bg: #fbf8f3;
  --card: #ffffff;
  --ok: #2f6b3a;
  --err: #a12626;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--maroon); }
a:hover { color: var(--maroon-dark); }
img { max-width: 100%; }
.wrap { width: 100%; max-width: none; margin: 0; padding: 0 clamp(16px, 3vw, 56px); }
.page { padding-top: 28px; padding-bottom: 48px; min-height: 60vh; }

/* Header */
.site-header { background: var(--maroon); color: #fff; border-bottom: 4px solid var(--gold); position: sticky; top: 0; z-index: 100; }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.brand small { display: block; opacity: .8; font-size: .78rem; }
.brand-logo { width: 71px; height: 61px; object-fit: contain; flex: none; }
.brand strong { font-size: .98rem; }
.main-nav { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; flex: none; }
.brand { min-width: 0; }
.main-nav a { color: #fff; text-decoration: none; padding: 8px 9px; border-radius: 6px; font-size: .92rem; white-space: nowrap; }
.main-nav a:hover, .main-nav a.on { background: rgba(255,255,255,.14); }
.main-nav .btn-nav { background: var(--gold); color: #2a1d05; font-weight: 600; margin-left: 4px; }
.main-nav .btn-nav:hover { background: #dba93a; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.6rem; cursor: pointer; }
@media (max-width: 980px) {
  .nav-toggle { display: block; }
  .main-nav { display: none; position: absolute; left: 0; right: 0; top: 72px; background: var(--maroon-dark); padding: 10px 16px; flex-direction: column; align-items: stretch; z-index: 10; }
  .nav-open .main-nav { display: flex; }
  .site-header { position: sticky; }
}

/* Typography & blocks */
h1 { font-size: 1.8rem; margin: 0 0 6px; color: var(--maroon-dark); }
h2 { font-size: 1.3rem; margin: 32px 0 14px; color: var(--maroon-dark); }
h2:first-child { margin-top: 0; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

.hero { background: linear-gradient(135deg, var(--maroon) 0%, var(--maroon-dark) 100%); color: #fff; border-radius: var(--radius); padding: 40px 28px; margin-bottom: 28px; border-bottom: 4px solid var(--gold); }
.hero { display: flex; align-items: center; gap: 18px; }
.hero-logo { width: 97px; height: 97px; object-fit: contain; flex: none;}
@media (max-width: 560px) { .hero { flex-direction: column; text-align: center; padding: 28px 18px; } }
.hero h1 { color: #fff; font-size: 2rem; }
.hero p { margin: 8px 0 0; max-width: 620px; opacity: .92; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.card h3 a { text-decoration: none; }
.stat { text-align: center; }
.stat b { display: block; font-size: 2rem; color: var(--maroon); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }

.person { text-align: center; }
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--gold-soft); color: var(--maroon); display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700; border: 3px solid var(--gold-soft); margin-bottom: 8px; }
.person .role { color: var(--muted); font-size: .9rem; }

.tag { display: inline-block; background: var(--gold-soft); color: #6b4d0c; border-radius: 999px; padding: 1px 10px; font-size: .78rem; font-weight: 600; }
.tag.off { background: #eee; color: #666; }

.meta { color: var(--muted); font-size: .9rem; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
@media (max-width: 560px) { .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; } }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f5efe5; font-size: .85rem; color: var(--maroon-dark); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }

/* Forms & buttons */
.search { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfc6ba; border-radius: 7px; font: inherit; background: #fff;
}
.search input { flex: 1; min-width: 180px; width: auto; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-weight: 600; margin: 0 0 4px; font-size: .92rem; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: .82rem; font-weight: 400; }
.btn { display: inline-block; background: var(--maroon); color: #fff; border: 0; border-radius: 7px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--maroon-dark); color: #fff; }
.btn.alt { background: #fff; color: var(--maroon); border: 1px solid var(--maroon); }
.btn.alt:hover { background: var(--gold-soft); }
.btn.danger { background: var(--err); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.pager { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager span { padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: #fff; }
.pager span { background: var(--maroon); color: #fff; border-color: var(--maroon); }

.flash { padding: 10px 14px; border-radius: 7px; margin-bottom: 16px; }
.flash.ok { background: #e6f2e8; color: var(--ok); border: 1px solid #bcd9c1; }
.flash.err { background: #fbe9e9; color: var(--err); border: 1px solid #ecc2c2; }

.richtext p { margin: 0 0 1em; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: .88rem; padding: 18px 0; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Admin */
.admin { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.side { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; position: sticky; top: 88px; }
.side a { display: block; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.side a:hover, .side a.on { background: var(--gold-soft); color: var(--maroon-dark); }
.side .sep { margin: 8px 12px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
@media (max-width: 820px) { .admin { grid-template-columns: 1fr; } .side { position: static; } }
.formcard { max-width: 720px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.thumb { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.login-box { max-width: 380px; margin: 40px auto; }
.login-logo { display: block; width: 100%; max-width: 206px; height: auto; margin: 0 auto 14px; }

/* ---- Foto pandita / pengurus (ditambahkan; aturan logo di atas tidak diubah) ---- */
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.foto-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.foto-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); transition: box-shadow .15s, transform .15s; }
.foto-card:hover { box-shadow: 0 6px 18px rgba(60, 20, 20, .14); transform: translateY(-2px); color: var(--ink); }
.foto-box { aspect-ratio: 3 / 4; background: var(--gold-soft); display: flex; align-items: center; justify-content: center; }
.foto-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { font-size: 2.6rem; font-weight: 700; color: var(--maroon); }
.foto-info { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.foto-info strong { line-height: 1.25; }
.detail-head { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.detail-foto { width: 240px; max-width: 100%; aspect-ratio: 3 / 4; background: var(--gold-soft); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; flex: none; border: 1px solid var(--line); }
.detail-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-info { flex: 1 1 320px; min-width: 0; }
.detail-info h1 { margin-top: 0; }
@media (max-width: 560px) { .foto-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } .detail-foto { width: 100%; max-width: 260px; } }

/* ---- Popup pembesar foto ---- */
[data-zoom] { cursor: zoom-in; }
.foto-nama { color: var(--ink); font-weight: 700; line-height: 1.25; text-decoration: none; }
.foto-nama:hover { color: var(--maroon); text-decoration: underline; }
a.foto-box { text-decoration: none; }
.lb { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 8, 8, .86); display: flex; align-items: center; justify-content: center; padding: 24px; }
.lb[hidden] { display: none; }
.lb-fig { margin: 0; max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lb-img { max-width: min(92vw, 900px); max-height: 80vh; width: auto; height: auto; border-radius: 8px; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); cursor: default; }
.lb-cap { color: #fff; text-align: center; font-size: 1rem; }
.lb-link { color: var(--gold); margin-left: 10px; font-weight: 600; }
.lb-link:hover { color: #f0c866; }
.lb-close { position: absolute; top: 14px; right: 18px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; }
.lb-close:hover { background: rgba(255, 255, 255, .3); }
body.lb-open { overflow: hidden; }

/* ---- Label tipe kegiatan yang panjang boleh turun baris ---- */
.tag { max-width: 100%; white-space: normal; border-radius: 12px; }

/* ---- Monitoring program kerja ---- */
.mon-table { font-size: .85rem; }
.mon-table th.c, .mon-table td.c { text-align: center; min-width: 46px; max-width: 84px; }
.mon-table td.lbl { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.mon-table tr.kat td { background: var(--gold-soft); font-weight: 700; }
.mon-table td small { display: block; overflow-wrap: anywhere; font-size: .68rem; color: var(--muted); line-height: 1.15; }
.mon-table tr.actual td { border-bottom: 2px solid var(--line); }
.mon-table td.ok, .mon.ok { background: #d9efdc; }
.mon-table td.part, .mon.part { background: #fff1c2; }
.mon-table td.late, .mon.late { background: #f8d4d4; }
.mon-table td.wait, .mon.wait { background: #eeeeee; }
.mon-table td.extra, .mon.extra { background: #d6e6f7; }
.mon-legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; font-size: .82rem; }
.mon-legend .mon { padding: 2px 10px; border-radius: 999px; }
@media print {
  .side, .site-header, .noprint, .flash { display: none !important; }
  .admin { display: block; }
  .table-wrap { overflow: visible; }
}

/* ---- Pilihan centang (bersedia melayani) ---- */
.checks { display: grid; gap: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { width: auto; margin-top: 4px; flex: none; }
ul.plain { margin: 0; padding-left: 18px; }

/* ---- Laporan ---- */
.laporan { font-size: .85rem; }
.laporan td, .laporan th { vertical-align: top; }
.err-text { color: #a12626; font-weight: 600; font-size: .8rem; }

/* ---- Urut kolom ---- */
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort:hover { text-decoration: underline; }
th a.sort .sort-ar { opacity: .35; font-size: .8em; }
th a.sort.on .sort-ar { opacity: 1; }
table.sortable th[data-s] { cursor: pointer; user-select: none; white-space: nowrap; }
table.sortable th[data-s]::after { content: " ⇅"; opacity: .35; font-size: .8em; }
table.sortable th[aria-sort="ascending"]::after { content: " ▲"; opacity: 1; }
table.sortable th[aria-sort="descending"]::after { content: " ▼"; opacity: 1; }
@media print { th a.sort .sort-ar, table.sortable th[data-s]::after { display: none; } }

/* Laporan: lebar kolom tetap (diatur di laporan.php) */
.laporan.fixed { table-layout: fixed; min-width: 100%; }
.laporan.fixed td, .laporan.fixed th { overflow-wrap: anywhere; }
.laporan.fixed td.nw { white-space: nowrap; overflow-wrap: normal; }
.laporan.fixed th { white-space: normal; }
@media print { .laporan.fixed { width: 100% !important; table-layout: auto; font-size: .68rem; } }

/* Tanda ketua lembaga */
.ketua { color: #c8962b; font-weight: 700; }

/* Flyer berita */
.flyers { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.flyer { flex: 0 0 auto; margin: 0; width: 240px; scroll-snap-align: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.flyer img { display: block; width: 100%; height: 300px; object-fit: contain; background: var(--gold-soft); border-radius: 6px; cursor: zoom-in; }
.flyer figcaption { font-size: .9rem; margin-top: 6px; line-height: 1.3; }
.flyer figcaption a { text-decoration: none; }
.berita-img { display: block; width: 100%; max-height: 260px; object-fit: contain; background: var(--gold-soft); border-radius: 6px; margin-bottom: 10px; }
.flyer-full { display: block; max-width: 100%; max-height: 80vh; border-radius: var(--radius); border: 1px solid var(--line); cursor: zoom-in; }

/* Kategori berita */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; vertical-align: middle; }
.badge.rencana { background: #fff1c2; color: #7a5200; }
.badge.berita { background: #d9efdc; color: #1d5a2b; }

.badge.out { background: #f8d4d4; color: #8a1c1c; }
.field .static { padding: 8px 0; font-weight: 600; }

/* Laporan kas */
.kas-head { text-align: center; margin: 4px 0 14px; }
.kas-org { font-weight: 700; font-size: 1.05rem; }
.kas-title { font-weight: 800; font-size: 1.25rem; letter-spacing: .04em; margin: 2px 0 4px; }
.laporan.kas th.num, .laporan.kas td.num { text-align: right; white-space: nowrap; }
.laporan.kas tr.tot td { font-weight: 700; background: var(--gold-soft); }
.kas-rek { margin-top: 18px; }
.kas-foot { font-size: .85rem; color: var(--muted, #666); margin-top: 14px; }
.kas-ttd { display: none; }
@media print {
  .kas-ttd { display: flex; justify-content: space-between; margin-top: 28px; text-align: center; }
  .laporan.kas { width: 100%; font-size: .78rem; }
  .kas-rek, .laporan.kas tr { break-inside: avoid; }
}

.search select { width: auto; max-width: 100%; }

/* Jadwal Pandita (timeline) */
.jp-filter { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin: 10px 0; }
.jp-filter label { display: flex; flex-direction: column; font-size: .85rem; gap: 2px; }
.jp-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line, #ddd); border-radius: 8px; }
table.jp { border-collapse: separate; border-spacing: 0; font-size: .8rem; width: max-content; }
table.jp th, table.jp td { border-right: 1px solid #eee; border-bottom: 1px solid #eee; min-width: 28px; height: 30px; text-align: center; padding: 0 2px; background: #fff; }
table.jp th, table.jp td { box-sizing: border-box; }
table.jp .jp-bln { background: #f3ede0; position: sticky; top: 0; z-index: 2; text-align: left; padding-left: 8px; }
table.jp .jp-d, table.jp .jp-w { background: #faf7ef; font-weight: 600; position: sticky; z-index: 2; }
table.jp .jp-d { top: 30px; }
table.jp .jp-w { top: 60px; }
table.jp .jp-d.we, table.jp .jp-w.we { background: #f0e9e9; }
table.jp .jp-d.today { background: #fff1c2; }
table.jp .jp-w { font-weight: 400; color: #777; font-size: .7rem; }
table.jp .we { background: #f6f1f1; }
table.jp .today { background: #fff1c2; }
table.jp th.jp-name { position: sticky; left: 0; z-index: 3; min-width: 170px; text-align: left; padding: 0 8px; background: #faf7ef; white-space: nowrap; }
table.jp tr:first-child th.jp-name { top: 0; z-index: 4; }
a.jp-star, .jp-star { color: #d98e00; font-size: 1.15rem; text-decoration: none; position: relative; display: inline-block; cursor: pointer; }
.jp-star sup { font-size: .6rem; color: #7a5200; }
.jp-tip { display: none; position: absolute; z-index: 10; left: 50%; top: 100%; transform: translateX(-50%); width: 230px; text-align: left; white-space: normal; background: #2b2b2b; color: #fff; padding: 8px 10px; border-radius: 6px; font-size: .78rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.jp-star:hover .jp-tip, .jp-star:focus .jp-tip { display: block; }
.jp-tip hr { border: 0; border-top: 1px solid #666; margin: 6px 0; }
.alasan-form { display: flex; flex-direction: column; gap: 4px; min-width: 170px; }
.alasan-form input[type=text] { padding: 4px 6px; font-size: .8rem; }
.alasan-form .btn { align-self: flex-start; }

/* Dashboard analitik pandita */
.ap-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 12px 0 6px; }
.ap-card { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 10px; background: #fff; border: 1px solid #e4dccb; border-left: 5px solid #7b1e1e; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.ap-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-2px); }
.ap-card.pasif { border-left-color: #8a8a8a; }
.ap-card.ok { border-left-color: #2f7d4f; }
.ap-card.no { border-left-color: #b3392f; }
.ap-num { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.ap-box { margin-top: 22px; background: #fff; border: 1px solid #e4dccb; border-radius: 10px; padding: 14px 16px; }
.ap-box h2 { margin: 0 0 2px; font-size: 1.1rem; }
.ap-legend { margin-top: 10px; font-size: .85rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ap-legend .ap-seg { width: 16px; height: 12px; display: inline-block; border-radius: 3px; }
.ap-bars { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ap-row { display: grid; grid-template-columns: minmax(130px, 280px) 1fr 36px; gap: 10px; align-items: center; }
.ap-lbl { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-track { display: flex; height: 24px; background: #f6f2e8; border-radius: 4px; overflow: hidden; }
.ap-seg { display: flex; align-items: center; justify-content: center; color: #fff; font-size: .75rem; font-weight: 700; min-width: 22px; }
.ap-seg.ok { background: #2f7d4f; }
.ap-seg.no { background: #b3392f; }
.ap-seg.wait { background: #a9a9a9; }
.ap-tot { font-weight: 700; text-align: right; }
@media (max-width: 640px) { .ap-row { grid-template-columns: 1fr 36px; } .ap-lbl { grid-column: 1 / -1; } .ap-track { grid-column: 1; } }

/* Anggota pandita pada permintaan */
.anggota-box { margin: 6px 0; }
.anggota-box summary { display: inline-block; cursor: pointer; list-style: none; }
.anggota-box summary::-webkit-details-marker { display: none; }
.anggota-form { margin-top: 6px; padding: 8px; background: #fff; border: 1px solid #e4dccb; border-radius: 8px; min-width: 230px; }
.anggota-form .ag-cari { width: 100%; padding: 4px 6px; font-size: .8rem; margin-bottom: 6px; }
.ag-list { max-height: 200px; overflow: auto; display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; font-size: .85rem; }
.ag-list label { display: flex; gap: 6px; align-items: center; cursor: pointer; }

/* Halaman publik Vihara/Cetiya */
.vihara-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; margin-top: 12px; }
.vihara-card { display: flex; flex-direction: column; gap: 12px; padding: 0; overflow: hidden; }
.vihara-foto { height: 180px; overflow: hidden; cursor: zoom-in; background: #f0e9d8; }
.vihara-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vihara-body { padding: 14px 16px 16px; }
.vihara-body h2 { margin: 0 0 8px; font-size: 1.15rem; }
.vihara-jadwal { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #e4dccb; }
.vihara-jadwal ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: .88rem; }
@media (max-width: 480px) { .vihara-grid { grid-template-columns: 1fr; } }
