/* ═══════════════════════════════════════════════════════════
   NTKST Temple Management — Main Stylesheet
   Colors: Green #136d54  |  Blue #98c7e7  |  Mint #f0f9f6
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
  --red:       #136d54;
  --red-dark:  #0f5542;
  --red-light: #e6f4ef;
  --gold:      #98c7e7;
  --gold-dark: #5da5d4;
  --gold-light:#e8f4fb;
  --cream:     #f0f9f6;
  --white:     #FFFFFF;
  --dark:      #2D2D2D;
  --grey-900:  #1A1A1A;
  --grey-700:  #374151;
  --grey-500:  #6B7280;
  --grey-300:  #D1D5DB;
  --grey-200:  #E5E7EB;
  --grey-100:  #F3F4F6;
  --sidebar-w: 260px;
  --topbar-h:  64px;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  background: var(--grey-100);
  color: var(--dark);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }

img { max-width: 100%; display: block; }

/* ─── LAYOUT ─────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────── */

#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--dark);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  background: var(--red);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  flex-shrink: 0;
}

.sidebar-title { flex: 1; min-width: 0; }
.sidebar-name-cn { font-size: 12px; font-weight: 700; color: var(--gold); line-height: 1.2; }
.sidebar-name-en { font-size: 9px; color: rgba(255,255,255,.75); line-height: 1.3; margin-top: 1px; word-break: break-word; }

.sidebar-close { display: none; background: none; border: none; color: #fff; cursor: pointer; padding: 4px; }
.sidebar-close .icon { width: 20px; height: 20px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--dark);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { margin-top: 3px; display: inline-block; font-size: 10px; }

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  padding: 16px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: rgba(255,255,255,.7);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px 6px;
  transition: all .15s;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--red); color: #fff; }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-label { white-space: nowrap; }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lang-switch {
  display: flex;
  gap: 4px;
}

.lang-btn {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: transparent;
  color: rgba(255,255,255,.6);
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.lang-btn.active { background: var(--gold); border-color: var(--gold); color: var(--dark); }
.lang-btn:hover:not(.active) { border-color: rgba(255,255,255,.5); color: #fff; }

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}

#sidebar-overlay.show { display: block; }

/* ─── MAIN CONTENT ───────────────────────────────────────── */

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── TOPBAR ─────────────────────────────────────────────── */

#topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--grey-700);
  padding: 4px;
}

.topbar-menu-btn .icon { width: 22px; height: 22px; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--dark); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

#topbar .lang-switch .lang-btn { border-color: var(--grey-300); color: var(--grey-500); }
#topbar .lang-switch .lang-btn.active { background: var(--red); border-color: var(--red); color: #fff; }

/* ─── PAGE CONTENT ───────────────────────────────────────── */

.page-content {
  flex: 1;
  padding: 24px;
}

/* ─── CARDS ──────────────────────────────────────────────── */

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.card-body { padding: 20px; }

/* ─── STAT CARDS ─────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--red);
}

.stat-card.gold { border-left-color: var(--gold); }
.stat-card.green { border-left-color: #16a34a; }
.stat-card.blue  { border-left-color: #2563eb; }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.red    { background: var(--red-light); color: var(--red); }
.stat-icon.gold   { background: var(--gold-light); color: var(--gold-dark); }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon .icon  { width: 24px; height: 24px; }

.stat-info {}
.stat-label { font-size: 12px; color: var(--grey-500); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--dark); line-height: 1.2; }
.stat-sub   { font-size: 11px; color: var(--grey-500); margin-top: 2px; }

.stat-trend { font-weight: 700; }
.stat-trend.up   { color: #16a34a; }
.stat-trend.down { color: #dc2626; }

.mini-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.mini-stat { text-align: center; padding: 8px 12px; }
.mini-stat-value { font-size: 22px; font-weight: 700; color: var(--dark); line-height: 1.2; }
.mini-stat-label { font-size: 12px; color: var(--grey-500); margin-top: 4px; }

/* Bilingual stacked labels: Chinese above, English below */
.bi-cn, .bi-en { display: block; }
.bi-en { font-size: 0.9em; color: var(--grey-400); }

/* ─── BUTTONS ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn .icon { width: 16px; height: 16px; }

.btn-primary  { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }

.btn-gold     { background: var(--gold); color: var(--dark); border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); }

.btn-outline  { background: transparent; color: var(--dark); border-color: var(--grey-300); }
.btn-outline:hover { border-color: var(--grey-500); background: var(--grey-100); }

.btn-ghost    { background: transparent; color: rgba(255,255,255,.75); border-color: transparent; }
.btn-ghost:hover { color: #fff; background: rgba(255,255,255,.08); }

.btn-danger   { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.btn-success  { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── FORMS ──────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-700);
  margin-bottom: 5px;
}

.form-label .req { color: var(--red); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--grey-300);
  border-radius: 6px;
  font-size: 14px;
  color: var(--dark);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(19,109,84,.12);
}

.form-control::placeholder { color: var(--grey-300); }

select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; appearance: none; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }

.detail-value {
  padding: 9px 12px;
  border: 1.5px solid var(--grey-200);
  border-radius: 6px;
  font-size: 14px;
  color: var(--dark);
  background: var(--grey-100);
  min-height: 38px;
  display: flex;
  align-items: center;
}
.form-full { grid-column: 1 / -1; }
.form-section-heading {
  font-size: 11px;
  font-weight: 700;
  color: var(--grey-500);
  letter-spacing: .7px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--grey-200);
  padding-bottom: 6px;
  margin: 20px 0 14px;
  grid-column: 1 / -1;
}

/* ─── NICHE DETAIL VIEW ──────────────────────────────────── */

.niche-detail-section {
  border: 1px solid var(--grey-200);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
  grid-column: 1 / -1;
}
.niche-detail-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--cream);
  border-bottom: 1px solid var(--grey-200);
  font-size: 13px;
  font-weight: 700;
  color: var(--red-dark);
  letter-spacing: .02em;
}
.niche-detail-section-header .icon { width: 16px; height: 16px; }
.niche-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  padding: 14px;
}
.niche-detail-item-full { grid-column: 1 / -1; }
.niche-detail-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 3px;
}
.niche-detail-value {
  font-size: 14px;
  color: var(--dark);
  font-weight: 500;
  word-break: break-word;
  white-space: pre-wrap;
}
.niche-detail-value.empty { color: var(--grey-300); font-style: italic; font-weight: 400; }
.niche-detail-fee-total .niche-detail-value { font-weight: 700; color: var(--red-dark); font-size: 16px; }
.niche-detail-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fef3c7;
  color: #b45309;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  grid-column: 1 / -1;
}
.niche-detail-pending .icon { width: 16px; height: 16px; }

@media (max-width: 768px) {
  .niche-detail-grid { grid-template-columns: 1fr; }
}

/* ─── TABLE ──────────────────────────────────────────────── */

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  background: var(--grey-100);
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--grey-500);
  border-bottom: 2px solid var(--grey-200);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--grey-200);
  color: var(--dark);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--cream); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.row-clickable { cursor: pointer; }
.table th.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.table th.th-sortable:hover { color: var(--red); }

/* ─── BADGES ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-red    { background: var(--red-light); color: var(--red); }
.badge-gold   { background: var(--gold-light); color: var(--gold-dark); }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-purple { background: #f3e8ff; color: #7c3aed; }
.badge-indigo { background: #e0e7ff; color: #3730a3; }
.badge-grey   { background: var(--grey-200); color: var(--grey-700); }
.badge-deceased { background: #ff3131; color: #fff; }

/* ─── CALENDAR ───────────────────────────────────────────── */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--grey-200);
  border-left: 1px solid var(--grey-200);
}

.cal-weekday {
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-500);
  background: var(--grey-100);
  border-right: 1px solid var(--grey-200);
  border-bottom: 1px solid var(--grey-200);
}

.cal-day {
  min-height: 100px;
  padding: 6px;
  border-right: 1px solid var(--grey-200);
  border-bottom: 1px solid var(--grey-200);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-day:hover { background: var(--grey-100); }

.cal-day-empty { cursor: default; background: var(--grey-100); }
.cal-day-empty:hover { background: var(--grey-100); }

.cal-day-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-700);
}

.cal-day-today .cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--dark);
}

.cal-day-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-shift-chip {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
}

.cal-shift-tag { opacity: 0.8; font-weight: 700; flex-shrink: 0; }

@media (max-width: 768px) {
  .cal-weekday { font-size: 10px; padding: 4px; }
  .cal-day { min-height: 70px; font-size: 11px; padding: 4px; }
  .cal-shift-chip { font-size: 9px; padding: 1px 4px; }
}

/* ─── FILTERS BAR ────────────────────────────────────────── */

.filters-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-input-wrap .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--grey-500);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1.5px solid var(--grey-300);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
}

.search-input:focus { outline: none; border-color: var(--red); }

/* ─── MODALS ─────────────────────────────────────────────── */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.open { display: flex; }

.modal-dialog {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s ease;
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--grey-500); padding: 2px;
  line-height: 0;
}

.modal-close:hover { color: var(--dark); }
.modal-close .icon { width: 20px; height: 20px; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--grey-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── TOAST ──────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(20px);
  transition: all .25s;
  max-width: 320px;
}

.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: #f0fdf4; color: #15803d; border-left: 4px solid #16a34a; }
.toast-error   { background: #fef2f2; color: #b91c1c; border-left: 4px solid #dc2626; }
.toast-info    { background: #eff6ff; color: #1d4ed8; border-left: 4px solid #3b82f6; }
.toast-warning { background: #fffbeb; color: #b45309; border-left: 4px solid #f59e0b; }

/* ─── PAGINATION ─────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding: 16px;
}

.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--grey-300);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-700);
  transition: all .15s;
}

.page-btn .icon { width: 16px; height: 16px; }
.page-btn:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.page-btn.active { background: var(--red); border-color: var(--red); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── STATES ─────────────────────────────────────────────── */

.empty-state, .loading-state, .error-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--grey-500);
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--grey-200);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* ─── ICON HELPER ────────────────────────────────────────── */

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon svg { width: 100%; height: 100%; }

/* ─── LOGIN PAGE ─────────────────────────────────────────── */

/* ─── LOGIN PAGE ─────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
}

/* Left branding panel */
.login-brand {
  width: 42%;
  background: linear-gradient(160deg, #072b1f 0%, #0f5542 55%, var(--red) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.login-brand::before {
  content: '';
  position: absolute;
  width: 420px; height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(152,199,231,.12);
  top: -100px; right: -120px;
  pointer-events: none;
}
.login-brand::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  border: 1px solid rgba(152,199,231,.08);
  bottom: -80px; left: -80px;
  pointer-events: none;
}

.login-brand-inner {
  text-align: center;
  position: relative;
  z-index: 1;
}

.login-brand-logo {
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 3px solid rgba(152,199,231,.55);
  margin: 0 auto 22px;
  box-shadow: 0 8px 36px rgba(0,0,0,.35);
  display: block;
}

.login-brand-cn {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .1em;
  margin-bottom: 12px;
}

.login-brand-divider {
  width: 44px;
  height: 2px;
  background: var(--gold);
  margin: 0 auto 14px;
  border-radius: 2px;
}

.login-brand-en {
  font-size: 9.5px;
  color: rgba(255,255,255,.65);
  text-transform: uppercase;
  letter-spacing: .14em;
  line-height: 1.7;
  margin-bottom: 22px;
}

.login-brand-tagline {
  font-size: 12.5px;
  color: rgba(255,255,255,.45);
  line-height: 1.8;
}

/* Right form panel */
.login-form-panel {
  flex: 1;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}

.login-form-wrap {
  width: 100%;
  max-width: 380px;
}

.login-greeting {
  margin-bottom: 30px;
}

.login-greeting h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
}

.login-greeting p {
  font-size: 13px;
  color: var(--grey-500);
}

.login-form-wrap .form-group { margin-bottom: 18px; }

.login-pw-wrap {
  position: relative;
}

.login-pw-wrap .form-control {
  padding-right: 44px;
}

.login-pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--grey-500);
  padding: 4px;
  line-height: 0;
}
.login-pw-toggle:hover { color: var(--dark); }
.login-pw-toggle .icon { width: 17px; height: 17px; }

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
  justify-content: center;
}

.login-admin-btn {
  background: none;
  border: 1px solid var(--grey-300);
  color: var(--grey-500);
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  font-family: inherit;
}
.login-admin-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.login-error {
  background: #fef2f2;
  color: #b91c1c;
  border-left: 3px solid #dc2626;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 20px;
  display: none;
}

.login-footer-note {
  text-align: center;
  margin-top: 32px;
  font-size: 11px;
  color: var(--grey-300);
}

@media (max-width: 680px) {
  .login-page { flex-direction: column; }
  .login-brand {
    width: 100%;
    padding: 36px 24px 30px;
  }
  .login-brand-logo { width: 84px; height: 84px; }
  .login-brand-cn   { font-size: 20px; }
  .login-brand-en   { font-size: 9px; }
  .login-form-panel { padding: 36px 24px; }
}

/* ─── CHART CONTAINER ────────────────────────────────────── */

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* ─── RECEIPT MODAL ──────────────────────────────────────── */

/* Fixed A5-landscape canvas (210mm x 148mm). The same element/CSS is used
   for the on-screen preview and for the printed/downloaded PDF, so the
   PDF is a 1:1 copy of the preview — no scaling or fit-to-page. */
.receipt-preview, .receipt-preview * {
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.receipt-preview {
  width: 210mm;
  height: 148mm;
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
}

/* Note: colors below are hard-coded (not var(--...)) and gaps are done via
   margins (not the flex `gap` property). html2canvas 1.4.1 does not reliably
   resolve CSS custom properties or flexbox `gap`, which caused color-tone
   shifts and vertical misalignment in the captured PDF vs. the live preview. */

.receipt-header {
  flex-shrink: 0;
  background: #136d54;
  padding: 16px 20px;
  display: flex;
  align-items: center;
}

.receipt-logo {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  flex-shrink: 0;
}

.receipt-temple-name { color: #fff; margin-left: 12px; }
.receipt-temple-cn { font-size: 15px; font-weight: 700; line-height: 1.3; color: #98c7e7; }
.receipt-temple-en { font-size: 10px; line-height: 1.3; color: rgba(255,255,255,.8); margin-top: 2px; }
.receipt-temple-addr { font-size: 10px; line-height: 1.3; color: rgba(255,255,255,.7); }

.receipt-title-bar {
  flex-shrink: 0;
  background: #98c7e7;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
  color: #2D2D2D;
  letter-spacing: .06em;
}

.receipt-body {
  flex: 1;
  overflow: hidden;
  padding: 20px 20px 36px;
}

.receipt-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.receipt-row-label {
  width: 150px;
  flex-shrink: 0;
  margin-right: 12px;
  font-weight: 600;
  color: #6B7280;
}

.receipt-row-value {
  flex: 1;
  color: #2D2D2D;
}

.receipt-divider {
  border: none;
  border-top: 1px dashed #D1D5DB;
  margin: 12px 0;
}

.receipt-total {
  background: #f0f9f6;
  border: 1px solid #98c7e7;
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 700;
}

.receipt-total-label { color: #374151; }
.receipt-total-value { color: #136d54; font-size: 18px; line-height: 1.3; }

.receipt-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #2D2D2D;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  text-align: center;
  font-size: 10px;
  line-height: 1.3;
  color: rgba(255,255,255,.5);
}

/* ─── RECEIPT PRINT (Ctrl+P / Save as PDF) ──────────────────── */
@page {
  size: A5 landscape;
  margin: 0;
}

@media print {
  html, body {
    width: 210mm;
    height: 148mm;
    margin: 0;
    padding: 0;
  }

  body * { visibility: hidden; }
  #receipt-preview-body, #receipt-preview-body * { visibility: visible; }

  .modal, .modal-dialog, .modal-body {
    position: static !important;
    overflow: visible !important;
    max-height: none !important;
    box-shadow: none !important;
    background: none !important;
    padding: 0 !important;
    border: none !important;
  }
  .modal-header, .modal-footer { display: none !important; }

  #receipt-preview-body {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    padding: 0;
  }
  .receipt-preview {
    width: 210mm;
    height: 148mm;
    margin: 0;
    transform: none;
    scale: 1;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }
}

/* ─── URN APPLICATION FORM (PDF) ─────────────────────────── */
/* Rendered off-screen at A4 width (210mm) and snapshotted via html2canvas
   into a multi-page PDF — see downloadUrnApplicationPDF() in urn-add.html. */
.urn-app-preview, .urn-app-preview * {
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.urn-app-preview {
  width: 210mm;
  box-sizing: border-box;
  padding: 20mm;
  background: #fff;
  font-family: inherit;
  color: #000;
  font-size: 11.5px;
}

.urn-app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 3px solid #000;
  padding: 1px 0 18px;
  margin-bottom: 20px;
}

.urn-app-logo { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.urn-app-temple-cn { font-size: 22px; font-weight: 700; color: #000; line-height: 1.3; }
.urn-app-temple-en { font-size: 15px; color: #000; line-height: 1.5; }

.urn-app-title {
  display: flex;
  align-items: top;
  justify-content: center;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #000;
  background: #fff;
  border: 2px solid #000;
  border-radius: 4px;
  padding: 6px 10px;
  margin: 0 0 14px;
}

.urn-app-section {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #000;
  border-bottom: 2px solid #000;
  padding-bottom: 4px;
  margin: 12px 0 6px;
}

.urn-app-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
}
.urn-app-grid-full { grid-template-columns: 1fr; }

.urn-app-row {
  display: flex;
  align-items: center;
  font-size: 11.5px;
  line-height: 1.4;
  padding: 3px 0;
  border-bottom: 1px dotted #999;
}
.urn-app-row-label { display: flex; flex-direction: column; width: 44%; flex-shrink: 0; color: #000; }
.urn-app-row-label-cn { font-weight: 700; font-style: italic; }
.urn-app-row-label-en { font-style: italic; color: #444; }
.urn-app-row-value { flex: 1; font-size: 12px; font-weight: 700; word-break: break-word; color: #000; padding-top: 1px; }
.urn-app-row-full { grid-column: 1 / -1; }
.urn-app-row-full .urn-app-row-label { width: 22%; }

.urn-app-family-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 3px;
  padding: 4px 8px;
  margin: 4px 0 4px;
}

.urn-app-inscription {
  display: flex;
  justify-content: center;
  border: 1px solid #000;
  border-radius: 6px;
  padding: 10px 16px;
  margin: 6px 0;
}
.urn-app-inscription-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  width: fit-content;
  height: 300px;
  font-size: 22px;
  font-weight: 700;
  font-family: 'Noto Serif SC', 'STSong', serif;
  letter-spacing: 2px;
  line-height: 1.4;
  color: #000;
}

.urn-app-declaration {
  font-size: 12.5px;
  line-height: 1.8;
  color: #000;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #000;
}

.urn-app-signatures {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin-top: 48px;
}
.urn-app-sig-block { flex: 1; }
.urn-app-sig-line {
  border-top: 1px solid #000;
  margin-top: 36px;
}
.urn-app-sig-caption {
  padding-top: 4px;
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  color: #000;
}
.urn-app-sig-date {
  padding-top: 2px;
  font-size: 11.5px;
  text-align: center;
  color: #444;
}

.urn-app-page-number {
  position: absolute;
  bottom: 8mm;
  right: 16mm;
  font-size: 10px;
  color: #000;
}

/* ─── TABS ───────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--grey-200);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-500);
  cursor: pointer;
  transition: all .15s;
}

.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }
.tab-btn:hover { color: var(--dark); }

/* ─── ITEMS TABLE (Incense Sale) ─────────────────────────── */

.items-table-wrap {
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.items-table th {
  background: var(--grey-100);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--grey-500);
}

.items-table td { padding: 8px 10px; border-top: 1px solid var(--grey-200); }

.items-table input, .items-table select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--grey-300);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close { display: flex; }

  .main-wrap { margin-left: 0; }

  .topbar-menu-btn { display: flex; }

  .page-content { padding: 16px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }

  .modal-dialog { max-width: 100%; max-height: 95vh; margin: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .search-input-wrap { max-width: 100%; }
}

/* ─── UTILITIES ──────────────────────────────────────────── */

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-auto { margin-top: auto; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-red { color: var(--red); }
.text-gold { color: var(--gold-dark); }
.text-grey { color: var(--grey-500); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.font-mono { font-family: monospace; }
.w-full { width: 100%; }
.actions-cell { display: flex; gap: 6px; align-items: center; }
.modal-open { overflow: hidden; }
