:root {
  --emerald-900:#0b2f26; --emerald-700:#134a3a; --emerald-500:#1d6b52;
  --gold:#b8924f; --gold-soft:#e7d6ad; --cream:#faf6ec; --panel:#fffdf7;
  --sage:#e4ebe1; --ink:#1c231f;
  --line: rgba(20,45,36,.14);
  --shadow: 0 18px 40px -22px rgba(11,47,38,0.35);
  /* legacy aliases re-pointed to new palette */
  --green: var(--emerald-700);
  --dark: var(--ink);
  --bg: var(--cream);
  --card: var(--panel);
  --side: var(--emerald-900);
  --accent: var(--gold);
  --muted: #6b7a71;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html{scroll-behavior:smooth;}
body {
  margin: 0;
  font-family:'Hind Siliguri', system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(184,146,79,0.10), transparent 60%),
    var(--cream);
  color: var(--ink);
  line-height:1.6;
}
body.sidebar-open { overflow: hidden; }
h1,h2,h3{ font-family:'Tiro Bangla', serif; font-weight:400; margin:0; color:var(--emerald-900); }

/* ===== LAYOUT SHELL (POS pattern) ===== */
.layout-shell { display: flex; min-height: 100vh; height: 100vh; overflow: hidden; }
.layout-main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: transparent; }
.layout-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 1rem; }
.layout-content-inner { max-width: 1020px; margin: 0 auto; }
@media (max-width: 639px) { .layout-content { padding: 0.75rem; } }

/* ===== SIDEBAR (POS pattern) — emerald re-skin ===== */
#appSidebar { position: fixed !important; top: 0; left: 0; bottom: 0; width: min(280px, 85vw) !important; max-width: 85vw; z-index: 50; transform: translateX(-100%); transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); display: flex !important; flex-direction: column !important; overflow: hidden !important; flex-shrink: 0; background: linear-gradient(180deg, var(--emerald-900), var(--emerald-700)); border-right: 1px solid rgba(231,214,173,0.12); }
#appSidebar.open { transform: translateX(0); }
@media (min-width: 1024px) {
  #appSidebar { position: static !important; transform: translateX(0) !important; max-width: none; width: 220px !important; min-width: 220px !important; transition: none !important; height: 100%; }
}
#mobileSidebarBackdrop { position: fixed; inset: 0; z-index: 40; background: rgba(11,47,38,0.5); -webkit-tap-highlight-color: transparent; }
#mobileSidebarBackdrop.hidden { display: none; }
@media (min-width: 1024px) { #mobileSidebarBackdrop { display: none !important; } }
.mobile-menu-btn { display: inline-flex; }
@media (min-width: 1024px) { .mobile-menu-btn { display: none !important; } }

.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 12px 10px; border-bottom: 1px solid rgba(231,214,173,0.14); flex-shrink: 0; text-decoration: none; }
.sidebar-brand-icon { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.08); border: 1.5px solid rgba(231,214,173,0.22); color: var(--gold-soft); flex-shrink: 0; font-size: 16px; }
.sidebar-brand-name { color: #fbf7ea; font-size: 12px; font-weight: 800; letter-spacing: 0.5px; line-height: 1.3; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family:'Tiro Bangla', serif; }
.sidebar-brand-sub { color: var(--gold-soft); font-size: 9px; font-weight: 500; line-height: 1.3; margin: 1px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1 1 0%; min-height: 0; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(231,214,173,0.18); border-radius: 4px; }
.sidebar-section-label { color: var(--gold-soft); font-size: 9px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; padding: 8px 6px 3px; user-select: none; opacity:0.85; }
.sidebar-link { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; color: #c9d6c7; font-size: 12px; font-weight: 500; text-decoration: none; transition: all 0.15s ease; line-height: 1.35; white-space: nowrap; overflow: hidden; min-height: 30px; }
@media (max-width: 1023px) { .sidebar-link { padding: 9px 10px; gap: 10px; min-height: 38px; font-size: 13px; white-space: normal; } }
.sidebar-link:hover { background: rgba(255, 255, 255, 0.07); color: #f4efe1; }
.sidebar-link.active { background: rgba(184,146,79,0.22); border:1px solid rgba(231,214,173,0.28); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(11,47,38,0.25); }
.sidebar-icon { width: 16px; height: 16px; flex-shrink: 0; display: block; }
.sidebar-expandable { display: flex; flex-direction: column; }
.sidebar-expand-btn { width: 100%; cursor: pointer; background: none; border: none; font-family: inherit; text-align: left; }
.sidebar-expand-btn.open { background: rgba(255, 255, 255, 0.07); color: #f4efe1; }
.sidebar-link-inner { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow: hidden; }
.sidebar-chevron { width: 14px; height: 14px; flex-shrink: 0; transition: transform 0.2s ease; color: var(--gold-soft); }
.sidebar-chevron.rotate-180 { transform: rotate(180deg); }
.sidebar-dropdown { display: flex; flex-direction: column; gap: 1px; padding-left: 14px; margin-top: 2px; border-left: 1.5px solid rgba(231,214,173,0.22); margin-left: 18px; }
.sidebar-dropdown.hidden { display: none; }
.sidebar-dropdown-item { display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 6px; color: #b8c7b5; font-size: 11px; font-weight: 500; text-decoration: none; transition: all 0.15s ease; white-space: nowrap; }
@media (max-width: 1023px) { .sidebar-dropdown-item { padding: 7px 10px; font-size: 12px; white-space: normal; } }
.sidebar-dropdown-item:hover { background: rgba(255, 255, 255, 0.06); color: #f4efe1; }
.sidebar-dropdown-item.active { background: var(--gold); color: var(--emerald-900); font-weight: 700; }
.sidebar-dropdown-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold-soft); flex-shrink: 0; }
.sidebar-dropdown-item.active .sidebar-dropdown-dot { background: var(--emerald-900); }

.sidebar-footer { flex-shrink: 0; padding: 8px; border-top: 1px solid rgba(231,214,173,0.14); background: rgba(11,47,38,0.35); }
.sidebar-user-card { display: flex; align-items: center; gap: 7px; padding: 7px 8px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(231,214,173,0.14); border-radius: 7px; }
.sidebar-user-avatar { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; background: rgba(184,146,79,0.18); border: 1px solid rgba(231,214,173,0.22); color: var(--gold-soft); flex-shrink: 0; }
.sidebar-user-name { color: #fbf7ea; font-size: 11px; font-weight: 600; line-height: 1.3; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { display: flex; align-items: center; gap: 4px; color: var(--gold-soft); font-size: 9px; font-weight: 500; margin: 2px 0 0; white-space: nowrap; }
.sidebar-user-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); flex-shrink: 0; }
.sidebar-logout-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin-top: 6px; padding: 6px 0; background: rgba(255,255,255,0.06); border: 1px solid rgba(231,214,173,0.14); border-radius: 6px; color: #f4efe1; font-size: 11px; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none; transition: all 0.15s ease; }
.sidebar-logout-btn:hover { background: rgba(184,146,79,0.18); color: #fff; }

/* ===== HEADER (POS pattern) ===== */
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; border-bottom: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); padding: 0.5rem 0.75rem; }
@media (min-width: 640px) { .app-header { padding: 0.6rem 1.25rem; } }
.app-header h2 { margin: 0; font-size: 1rem; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family:'Tiro Bangla', serif; color:var(--emerald-900); }
@media (min-width: 640px) { .app-header h2 { font-size: 1.15rem; } }
.mobile-menu-btn { align-items: center; justify-content: center; height: 36px; width: 36px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--emerald-900); cursor: pointer; }
.header-date { display: none; align-items: center; gap: 0.4rem; border: 1px solid var(--line); background: var(--sage); padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
@media (min-width: 640px) { .header-date { display: inline-flex; } }
.header-user { display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid var(--line); background: var(--panel); padding: 0.2rem 0.6rem 0.2rem 0.2rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; color:var(--emerald-900); }
.header-user .avatar { display: inline-flex; align-items: center; justify-content: center; height: 24px; width: 24px; border-radius: 50%; background: var(--emerald-700); color: var(--gold-soft); font-size: 0.7rem; font-weight: 800; }

/* ===== CONTENT (existing mosque styles, re-skinned) ===== */
.wrap { max-width: 1020px; margin: 1.2rem auto; padding: 0 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1rem 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 6px 6px; padding: 1rem 1.1rem; position:relative; box-shadow: var(--shadow); }
.card::before{ content:""; position:absolute; top:-1px; left:50%; transform:translateX(-50%); width:36px; height:3px; background:var(--gold); border-radius:0 0 3px 3px; }
.card h3 { margin: 0 0 0.3rem; font-size: 0.85rem; color: var(--emerald-700); font-weight: 600; font-family:'Hind Siliguri',sans-serif; }
.card .big { font-size: 1.45rem; font-weight: 700; color:var(--emerald-900); }
.card.mosque .big { color: var(--emerald-900); }
.card.mahfil .big { color: #6b4f1f; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; font-size: 0.93rem; border:1px solid var(--line); }
th, td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--sage); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; color:var(--emerald-900); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
/* ===== LIST CARDS (shared across all converted pages) ===== */
.record-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem 1rem; margin-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; box-shadow: var(--shadow); }
.record-card--income { border-left: 3px solid var(--emerald-500); }
.record-card--expense { border-left: 3px solid #b3261e; }
.record-card__header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.record-card__meta { font-size: 0.82rem; color: var(--muted); }
.record-card__body { display: flex; flex-direction: column; gap: 0.25rem; }
.record-card__body .row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
@media (max-width: 480px) { .record-card__body .row { grid-template-columns: 1fr; } }
.record-card__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.4rem; border-top: 1px solid var(--line); margin-top: 0.2rem; }
.record-card__actions .btn { font-size: 0.82rem; padding: 0.35rem 0.7rem; }
.record-card__actions--split .btn { flex: 1; text-align: center; }
.record-card__actions--triple .btn { flex: 1; text-align: center; }
/* Pager */
.pager { display: flex; gap: 0.5rem; justify-content: center; margin: 1rem 0; flex-wrap: wrap; }
.pager .btn { min-width: 80px; text-align: center; }
.pager .btn:disabled { opacity: 0.4; cursor: default; }
/* Mosque numbered pager */
.pager-mosque { display: flex; gap: 0.4rem; justify-content: center; margin: 1rem 0; flex-wrap: wrap; }
.pager-mosque__btn { font-size: 0.88rem; padding: 0.3rem 0.7rem; min-width: 36px; text-align: center; }
.pager-mosque__btn--active { background: var(--emerald-700); color: #fff; font-weight: 700; }
.pager-mosque__btn--disabled { opacity: 0.4; cursor: default; pointer-events: none; }
/* End of list note */
.list-empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); background:var(--sage); border:1px dashed var(--line); border-radius:12px; }
/* Horizontal scroll wrapper for wide tables on narrow screens. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.5rem 0; }
.table-scroll table { min-width: 560px; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.78rem; background: var(--sage); color: var(--emerald-700); border:1px solid var(--line); }
.badge.mahfil { background: #fdf1d7; color: #6b4f1f; border-color: rgba(184,146,79,0.25); }
.btn { display: inline-block; background: var(--emerald-700); color: #fff; border: 1px solid var(--emerald-900); border-radius: 8px; padding: 0.5rem 1rem; cursor: pointer; text-decoration: none; font-size: 0.93rem; font-weight:600; transition: filter 0.15s, background 0.15s; }
.btn:hover { filter: brightness(1.08); background: var(--emerald-500); }
.btn.danger { background: #b3261e; border-color:#8a1a14; }
.btn.ghost { background: var(--sage); color: var(--emerald-900); border:1px solid var(--line); }
.btn.ghost:hover{ background:#d9e2d5; }
form.inline { display: inline; }
input, select, textarea { width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; background: #fff; font-family:'Hind Siliguri',sans-serif; color:var(--ink); }
input:focus, select:focus, textarea:focus{ outline:none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184,146,79,0.15); }
label { display: block; margin: 0.7rem 0 0.25rem; font-weight: 600; font-size: 0.9rem; color:var(--emerald-900); }
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem; max-width: 620px; box-shadow: var(--shadow); position:relative; }
.form-card::before{ content:""; position:absolute; top:-1px; left:50%; transform:translateX(-50%); width:42px; height:3px; background:var(--gold); border-radius:0 0 3px 3px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }
/* Search input + button row — 80/20 split down to a sane minimum. */
.search-row { display: flex; gap: 0.6rem; align-items: stretch; margin-bottom: 1rem; }
.search-row input { flex: 0 0 calc(80% - 0.3rem); min-width: 0; }
.search-row button { flex: 0 0 20%; text-align: center; white-space: nowrap; }
@media (max-width: 480px) { .search-row { flex-wrap: wrap; } .search-row input { flex: 0 0 calc(100% - 0.6rem); } .search-row button { flex: 0 0 calc(100% - 0.6rem); } }
/* Global hide utility — panels and conditional fields rely on it. */
.hidden { display: none !important; }
/* Equal-width button pair (fund tabs, add-category buttons). */
.fund-tabs { display: flex; gap: 0.6rem; margin: 0.6rem 0; }
.fund-tabs .btn { flex: 1; text-align: center; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 1rem 0; }
.btn-pair .btn { text-align: center; }
@media (max-width: 640px) { .btn-pair { grid-template-columns: 1fr; } }
/* Modal save/cancel row — always equal-width at any screen size. */
.popup-actions { display: flex; gap: 0.8rem; margin-top: 1rem; }
.popup-actions .btn { flex: 1; text-align: center; }
.alert { padding: 0.6rem 0.9rem; border-radius: 8px; margin: 0.8rem 0; border:1px solid var(--line); }
.alert.success { background: #e7f4ec; color: var(--emerald-700); border-color: rgba(19,74,58,0.14); }
.alert.error { background: #fdecea; color: #b3261e; border-color: rgba(179,38,30,0.14); }
.toolbar { display: flex; gap: 0.6rem; align-items: end; flex-wrap: wrap; margin: 1rem 0; }
.toolbar .field { min-width: 160px; }
h1 { font-size: 1.45rem; margin: 0.4rem 0 0.8rem; color:var(--emerald-900); font-family:'Tiro Bangla', serif; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 0.6rem; color:var(--emerald-900); font-family:'Tiro Bangla', serif; }
.paid { color: var(--emerald-700); font-weight: 700; }
.unpaid { color: var(--muted); }
.grid-periods { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.grid-periods .p { border: 1px solid var(--line); border-radius: 6px; padding: 0.25rem 0.5rem; font-size: 0.82rem; background: var(--panel); }
.grid-periods .p.paid { background: var(--sage); border-color: var(--emerald-700); color:var(--emerald-900); }
.muted { color: var(--muted); font-size: 0.88rem; }
.hero { text-align: center; padding: 2rem 1rem 0.5rem; }
/* Public page brand block: logo beside the mosque name, login below. */
.brand { text-align: center; padding: 2rem 1rem 0.5rem; }
.brand img { height: 60px; width: auto; }
.brand h1 { margin: 0.4rem 0 0.8rem; }

/* ===== MODALS (plain hide/show popup, POS product-modal pattern) ===== */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 0.5rem; background: rgba(11,47,38,0.6); overflow-y: auto; }
@media (min-width: 640px) { .modal-backdrop { padding: 1rem; } }
.modal-backdrop.hidden { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 1rem); overflow-y: auto; padding: 1.2rem; box-shadow: var(--shadow); }
@media (min-width: 640px) { .modal-box { max-height: 90vh; padding: 1.2rem; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 0.6rem; margin-bottom: 0.4rem; }
.modal-head h3 { margin: 0; font-size: 1.05rem; font-family:'Tiro Bangla', serif; color:var(--emerald-900); }
.modal-head button { border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); }
/* Sidebar brand logo */
.sidebar-brand-logo { height: 32px; width: auto; flex-shrink: 0; border-radius: 4px; }
@media (max-width: 480px) { .sidebar-brand-logo { height: 26px; } }

/* Premium login hero for guest layout reuse */
.login-hero{ position:relative; overflow:hidden; background: linear-gradient(180deg, var(--emerald-900), var(--emerald-700) 70%, var(--emerald-500)); color:#f4efe1; padding: 32px 20px 44px; text-align:center; border-radius:0 0 22px 22px; margin: -1px -1px 0 -1px; }
.login-hero .arch{ width:88px; height:88px; margin:0 auto 14px; border:1.5px solid var(--gold-soft); border-radius:44px 44px 8px 8px; display:flex; align-items:center; justify-content:center; background: rgba(255,255,255,0.06); }
.login-hero .arch img{ width:52px; height:52px; object-fit:contain; border-radius:50%; }
.login-hero h1{ color:#fbf7ea; font-size:22px; margin:0; }
.login-hero p.sub{ color:var(--gold-soft); font-size:13px; margin-top:6px; letter-spacing:0.04em; }
