:root {
  --primary: #d21f1f;
  --primary-dark: #9a0f0f;
  --accent: #f9a825;
  --ink: #1b2430;
  --muted: #5a6675;
  --bg: #f6f8fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --success: #1f9d55;
  --error: #d13438;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
}
.brand-logo {
  height: 42px;
  width: auto;
  border-radius: 6px;
  display: block;
}
.brand-text { color: var(--ink); }
.brand-accent { color: var(--primary); }
.main-nav { display: flex; align-items: center; gap: 22px; }
.main-nav a { color: var(--ink); font-weight: 500; }
.main-nav a.active { color: var(--primary); }
.btn-nav {
  background: var(--primary);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none !important;
}
.btn-nav:hover { background: var(--primary-dark); }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 70px 0;
  text-align: center;
}
.hero h1 { font-size: 2.4rem; margin-bottom: 12px; }
.hero p { font-size: 1.15rem; opacity: 0.9; max-width: 620px; margin: 0 auto 26px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 1rem;
}
.btn-primary { background: var(--accent); color: #1b2430; }
.btn-primary:hover { background: #e67c11; text-decoration: none; }
.btn-outline { background: transparent; color: #fff; border: 2px solid #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.15); text-decoration: none; }
.btn-secondary { background: var(--primary); color: #fff; }
.btn-secondary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-danger { background: var(--error); color: #fff; }
.btn-small { padding: 6px 14px; font-size: 0.85rem; }

/* Sections */
section { padding: 55px 0; }
.section-title { text-align: center; margin-bottom: 40px; }
.section-title h2 { font-size: 1.9rem; margin-bottom: 8px; }
.section-title p { color: var(--muted); }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}
.card h3 { margin-top: 0; }
.icon-badge {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #fbe4e4;
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
}

/* Pricing table */
table.pricing {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}
table.pricing th, table.pricing td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.pricing th { background: var(--primary); color: #fff; }
table.pricing tr:last-child td { border-bottom: none; }
.price-tag { font-weight: 700; color: var(--primary-dark); }

/* Forms */
.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  max-width: 520px;
  margin: 0 auto;
}
.form-card.wide { max-width: 720px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.92rem; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}
.form-group textarea { resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(210, 31, 31, 0.12);
}

/* Chit month amount schedule table inputs */
#amountTable input[type="number"] {
  width: 100%;
  min-width: 100px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: right;
  background: #f8fafc;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
#amountTable input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(210, 31, 31, 0.12);
}
#amountTable input[type="number"]::-webkit-outer-spin-button,
#amountTable input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#amountTable input[type="number"] { -moz-appearance: textfield; }
.combobox { position: relative; }
.combobox-list {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 4px;
  max-height: 220px; overflow-y: auto; background: #fff;
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}
.combobox-item { padding: 8px 12px; cursor: pointer; font-size: 0.92rem; }
.combobox-item:hover { background: #f4f6f8; }
.combobox-item[hidden] { display: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.form-footer-link { text-align: center; margin-top: 16px; font-size: 0.92rem; }

.login-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.login-tab {
  flex: 1; text-align: center; padding: 10px 4px; font-weight: 600; font-size: 0.88rem;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.login-tab:hover { text-decoration: none; color: var(--ink); }
.login-tab.active:hover { color: var(--primary); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 64px; }
.toggle-password {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: none; border: none; color: var(--primary); font-size: 0.82rem;
  font-weight: 600; cursor: pointer; padding: 4px 8px;
}
.toggle-password:hover { text-decoration: underline; }

.photo-preview { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: #f4f6fb; }
.salary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .salary-grid { grid-template-columns: 1fr; } }

/* Alerts */
.alert {
  padding: 12px 18px;
  border-radius: 6px;
  margin: 18px 0;
  font-size: 0.95rem;
}
.alert-success { background: #e6f7ec; color: var(--success); border: 1px solid #b7e6c6; }
.alert-error { background: #fdecec; color: var(--error); border: 1px solid #f5c2c2; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Status badges */
.badge { padding: 3px 10px; border-radius: 12px; font-size: 0.78rem; font-weight: 600; display: inline-block; }
.badge-pending { background: #fff3cd; color: #8a6500; }
.badge-approved { background: #e6f7ec; color: var(--success); }
.badge-blocked { background: #fdecec; color: var(--error); }
.badge-new { background: #fbe4e4; color: var(--primary-dark); }
.badge-read { background: #eee; color: #555; }
.badge-resolved { background: #e6f7ec; color: var(--success); }
.badge-open { background: #e6f7ec; color: var(--success); }
.badge-closed { background: #fdecec; color: var(--error); }

/* Footer */
.site-footer { background: var(--ink); color: #cbd5e1; padding: 40px 0 16px; margin-top: 40px; }
.footer-wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.footer-wrap a { color: #cbd5e1; margin-right: 16px; }
.copyright { text-align: center; margin-top: 24px; font-size: 0.85rem; color: #8492a6; }

/* Admin layout */
.admin-body { background: var(--bg); }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 230px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #ffe2e2;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  /* Sidebar stays in place while the page scrolls; only its menu links scroll inside it. */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.35) transparent;
}
/* Logo/profile pinned to the top of the sidebar, Logout pinned to the bottom. */
.admin-sidebar .brand,
.admin-sidebar .sidebar-profile { position: sticky; top: 0; z-index: 2; background: var(--primary); flex-shrink: 0; }
.admin-sidebar .sidebar-bottom { position: sticky; bottom: 0; z-index: 2; background: var(--primary-dark); flex-shrink: 0; padding-bottom: 10px; }
.admin-sidebar .brand { color: #fff; padding: 24px 24px 20px; display: flex; border-bottom: 1px solid rgba(255,255,255,0.25); margin-bottom: 16px; }
.admin-sidebar .brand-text { color: #fff; }
.admin-sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 24px; color: #ffe2e2; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(0,0,0,0.18); color: #fff; text-decoration: none; }
.admin-sidebar a .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.admin-sidebar a.sub-link .nav-icon { width: 16px; height: 16px; }
.admin-main { flex: 1; min-width: 0; padding: 30px 34px 90px; position: relative; min-height: 100vh; box-sizing: border-box; }
/* Copyright bar at the bottom of every dashboard page: copyright left, website link right. */
.main-footer {
  position: absolute; left: 34px; right: 34px; bottom: 20px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 0.85rem; color: var(--muted);
}
.main-footer a { color: var(--primary); font-weight: 600; }
.admin-topbar {
  position: sticky; top: 0; z-index: 50; /* header stays fixed while the page content scrolls */
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 22px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.admin-profile { display: flex; align-items: center; gap: 10px; }
.admin-profile img.avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary); }
.admin-profile .avatar-circle {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.admin-profile .profile-info { display: flex; flex-direction: column; line-height: 1.25; }
.admin-profile .profile-name { font-weight: 600; color: var(--ink); font-size: 0.92rem; }
.admin-profile .profile-role { color: var(--muted); font-size: 0.78rem; }

/* Sidebar top profile card (image, name, designation) */
.sidebar-profile {
  text-align: center; padding: 20px 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.25); margin-bottom: 12px;
}
.sidebar-profile img {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 3px solid rgba(255,255,255,0.5); margin-bottom: 10px;
}
.sidebar-profile .sp-name { color: #fff; font-weight: 700; font-size: 1rem; }
.sidebar-profile .sp-role { color: rgba(255,255,255,0.75); font-size: 0.8rem; margin-top: 2px; }

.admin-sidebar .sidebar-section-label {
  padding: 10px 24px 4px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: rgba(255,255,255,0.6); margin-top: 6px;
}
.admin-sidebar a.sub-link { padding-left: 40px; font-size: 0.9rem; }
.admin-sidebar a.sub-link.level-2 { padding-left: 36px; font-size: 0.92rem; }
.admin-sidebar a.sub-link.level-3 { padding-left: 50px; font-size: 0.88rem; }
.admin-sidebar .menu-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  flex-shrink: 0;
  display: inline-block;
  margin-right: 6px;
}

/* Sidebar dropdown accordion */
.sidebar-dropdown {
  position: relative;
}
.sidebar-dropdown-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: transparent;
  border: none;
  color: #ffe2e2;
  font-family: inherit;
  font-size: 1rem;
  font-weight: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-dropdown-toggle:hover,
.sidebar-dropdown-toggle.active {
  background: rgba(0,0,0,0.18);
  color: #fff;
}
.sidebar-dropdown-toggle:focus {
  outline: none;
}
.sidebar-dropdown-toggle .toggle-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-dropdown-toggle .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.sidebar-dropdown-toggle .sidebar-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.75;
  transition: transform 0.2s ease;
}
.sidebar-dropdown.open > .sidebar-dropdown-toggle .sidebar-chevron {
  transform: rotate(90deg);
}

.sidebar-submenu {
  display: none;
  background: rgba(0, 0, 0, 0.12);
}
.sidebar-dropdown.open > .sidebar-submenu {
  display: block;
}

/* Sub-level toggle inside Account (Chit, Daily Collection) */
.sidebar-dropdown-toggle.sub-toggle {
  padding-left: 36px;
  font-size: 0.92rem;
}
.sidebar-dropdown-toggle.sub-toggle .nav-icon {
  width: 16px;
  height: 16px;
}

.admin-sidebar .sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,0.25); padding-top: 10px; }

/* Topbar right-side action group */
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-actions img.topbar-logo { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.stat-card .label { color: var(--muted); font-size: 0.9rem; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.92rem; }
table.data th { background: #eef2f7; }
table.data tr:last-child td { border-bottom: none; }
.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }

/* AJAX table controls */
.table-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 12px; }
.entries-control { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--muted); }
.entries-control select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.search-control input {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px;
  width: 280px; max-width: 100%; font-size: 0.92rem;
}
.table-filters { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.table-filters .filter-group { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.table-filters select, .table-filters input[type="date"] { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
.table-loading { text-align: center; padding: 24px; color: var(--muted); }
.table-pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; flex-wrap: wrap; gap: 10px; font-size: 0.88rem; color: var(--muted); }
.pagination-buttons { display: flex; align-items: center; gap: 6px; }
.pagination-buttons button {
  padding: 6px 14px; border: 1px solid var(--border); background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 0.85rem; color: var(--ink);
}
.pagination-buttons button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination-buttons button:not(:disabled):hover { border-color: var(--primary); color: var(--primary); }

/* Icon action buttons */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--ink); cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.icon-btn svg { width: 16px; height: 16px; pointer-events: none; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; background: #fff; color: var(--muted); border-color: var(--border); }
.icon-btn.icon-view:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn.icon-edit { background: var(--primary); border-color: var(--primary); color: #fff; }
.icon-btn.icon-edit:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.icon-btn.icon-approve { background: var(--success); border-color: var(--success); color: #fff; }
.icon-btn.icon-approve:hover { background: #16793f; border-color: #16793f; }
.icon-btn.icon-unblock { background: var(--success); border-color: var(--success); color: #fff; }
.icon-btn.icon-unblock:hover { background: #16793f; border-color: #16793f; }
.icon-btn.icon-block, .icon-btn.icon-delete { background: var(--error); border-color: var(--error); color: #fff; }
.icon-btn.icon-block:hover, .icon-btn.icon-delete:hover { background: #a3282c; border-color: #a3282c; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 20, 25, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 50px 16px; z-index: 1000; overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: var(--radius); max-width: 560px; width: 100%;
  padding: 30px; position: relative; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-box h3 { margin-top: 0; }
.modal-box-lg { max-width: 960px; }
/* Full-screen modal: the table scrolls between a sticky header and sticky totals row */
.modal-overlay-full { padding: 0; overflow: hidden; }
.modal-box-full {
  max-width: none; width: 100%; height: 100vh; height: 100dvh; border-radius: 0;
  padding: 20px 24px; display: flex; flex-direction: column;
}
.modal-box-full .modal-full-form { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.modal-box-full .modal-full-scroll { flex: 1; min-height: 0; overflow: auto; }
.modal-box-full thead th { position: sticky; top: 0; z-index: 1; background: #f8fafc; }
.modal-box-full tfoot th { position: sticky; bottom: 0; z-index: 1; background: #f8fafc; }
.modal-box-full .modal-full-submit { margin-top: 14px; flex-shrink: 0; }
@media (max-width: 640px) { .modal-box-full { padding: 16px; } }
.modal-close {
  position: absolute; top: 14px; right: 16px; border: none; background: none;
  font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1;
}
.modal-close:hover { color: var(--ink); }
.view-field { margin-bottom: 10px; font-size: 0.95rem; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.view-field:last-child { border-bottom: none; }

/* Modal tabs */
.modal-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.modal-tabs .tab-btn {
  padding: 10px 4px; border: none; background: none; cursor: pointer;
  font-size: 0.92rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-right: 18px;
}
.modal-tabs .tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.modal-tabs .tab-btn:hover:not(.active) { color: var(--ink); }
.view-field strong { display: block; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px; }

@media (max-width: 720px) {
  .main-nav { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; position: static; height: auto; overflow: visible; }
  .admin-sidebar .brand, .admin-sidebar .sidebar-profile, .admin-sidebar .sidebar-bottom { position: static; }
}

/* Sortable table headings (assets/js/table-sort.js): click to sort ascending, again for descending. */
th.th-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sortable::after { content: '\2195'; margin-left: 5px; font-size: 0.8em; opacity: 0.35; font-weight: 400; }
th.th-sortable:hover::after { opacity: 0.75; }
th.th-sortable.sort-asc::after { content: '\25B2'; opacity: 1; }
th.th-sortable.sort-desc::after { content: '\25BC'; opacity: 1; }
/* Page tabs (My Profile and others): 1. My Details / 2. Change Password */
.page-tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.page-tabs button { border:1px solid var(--border); background:#fff; color:var(--ink); padding:8px 16px; border-radius:8px; font-weight:600; cursor:pointer; font-family:inherit; }
.page-tabs button.active { background:var(--primary); border-color:var(--primary); color:#fff; }
.detail-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:4px 24px; }
.detail-grid .view-field { padding:6px 0; border-bottom:1px dotted var(--border); }