:root {
  --sidebar-width: 260px;
  --sidebar-bg: #172033;
  --sidebar-bg-hover: #232f47;
  --sidebar-text: #a9b4c9;
  --sidebar-text-active: #ffffff;
  --accent: #4f6df5;
  --accent-soft: rgba(79, 109, 245, 0.15);
  --content-bg: #f3f5f9;
}

* { box-sizing: border-box; }

/* ---------- Printable documents ---------- */
.print-page {
  max-width: 210mm;
  margin: 1.5rem auto;
  background: #fff;
  padding: 20mm 18mm;
  box-shadow: 0 1px 6px rgba(0,0,0,0.12);
  font-family: 'Sarabun', sans-serif;
  color: #1f2937;
}
.letterhead {
  text-align: center;
  border-bottom: 2px solid #1f2937;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
}
.letterhead-logo { display: flex; justify-content: center; margin-bottom: 0.4rem; }
.letterhead-village { font-size: 1.3rem; font-weight: 700; }
.letterhead-address { font-size: 0.85rem; color: #4b5563; }
.print-doc-title { text-align: center; font-size: 1.15rem; font-weight: 700; margin-bottom: 1.25rem; }
.print-signature { margin-top: 3.5rem; text-align: center; }
.print-toolbar { max-width: 210mm; margin: 1rem auto 0; text-align: right; }
@media print {
  body { background: #fff; }
  .print-toolbar, .no-print { display: none !important; }
  .print-page { box-shadow: none; margin: 0; max-width: none; padding: 10mm; }
}

body {
  font-family: 'Sarabun', sans-serif;
  background-color: var(--content-bg);
  margin: 0;
}

a { text-decoration: none; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

.sidebar-brand .brand-icon { font-size: 1.5rem; margin-right: 0.5rem; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--sidebar-text);
  background: transparent;
  border: none;
  font-size: 0.92rem;
  text-align: left;
  margin-bottom: 0.15rem;
}

.nav-link-item i:first-child { font-size: 1.05rem; width: 1.2rem; }

.nav-link-item:hover {
  background: var(--sidebar-bg-hover);
  color: #fff;
}

.nav-link-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-group-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-group-toggle .chevron {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.nav-group-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.nav-subgroup {
  padding-left: 1.1rem;
  border-left: 2px solid rgba(255, 255, 255, 0.08);
  margin: 0.1rem 0 0.35rem 1.1rem;
}

.nav-sublink { font-size: 0.87rem; padding: 0.5rem 0.65rem; }

.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
  min-width: 1.1rem;
  text-align: center;
}

.nav-link-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
}

.nav-group-end .nav-badge {
  margin-left: 0;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.sidebar-footer-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  padding: 0.25rem 0.75rem 0.5rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1035;
}

.sidebar-backdrop.show { display: block; }

/* ---------- Main / topbar ---------- */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e9f0;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title {
  font-weight: 600;
  color: #1f2937;
}

.sidebar-toggle {
  display: none;
  font-size: 1.3rem;
  border: none;
  background: transparent;
}

.app-content {
  padding: 1.5rem;
  flex: 1;
}

.app-footer {
  background: transparent;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: inline-block;
  }
}

/* ---------- Cards / tables ---------- */
.card {
  border: none;
  border-radius: 0.85rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.table thead th {
  background-color: #f8fafc;
  white-space: nowrap;
  font-weight: 600;
  color: #475569;
}

.btn { border-radius: 0.5rem; }
.btn-primary { background-color: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background-color: #3c58e0; border-color: #3c58e0; }

.dashboard-stat {
  border-radius: 0.85rem;
  padding: 1.25rem;
  color: #fff;
}

.dashboard-stat .stat-number {
  font-size: 2rem;
  font-weight: 700;
}

.stat-houses { background: linear-gradient(135deg, #4e73df, #3653c9); }
.stat-residents { background: linear-gradient(135deg, #1cc88a, #17a673); }
.stat-committee { background: linear-gradient(135deg, #f6c23e, #dda20a); }
.stat-pets { background: linear-gradient(135deg, #e74a3b, #c8392a); }
.stat-vehicles { background: linear-gradient(135deg, #36b9cc, #258391); }
