:root {
  color-scheme: light;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  /* Warm ivory/cream light theme — dark mode (below) is untouched. */
  --bg: #faf6ec;
  --card-bg: #fffdf7;
  --text: #2b2620;
  --muted: #83786a;
  --border: #e6ddc8;
  --error-bg: #fef2f2;
  --error-text: #b91c1c;

  /* Status palette (fixed — never themed) */
  --status-good: #0ca30c;
  --status-good-bg: #dcfce7;
  --status-warning: #fab219;
  --status-warning-bg: #fef9c3;
  --status-critical: #d03b3b;
  --status-critical-bg: #fee2e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Auth (full-screen, centered) ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* An author `display` rule beats the UA [hidden]{display:none} rule at equal
   specificity (author origin always wins) — without this, toggling the
   `hidden` property from JS does nothing visually. */
.auth-page[hidden] { display: none; }

.card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.brand span {
  font-weight: 400;
  color: var(--muted);
}

.tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 1.5rem;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: var(--brand);
  color: white;
}

.panel {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.panel.active {
  display: flex;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* An author `display` rule beats the UA [hidden]{display:none} rule at
   equal specificity — without this, toggling `hidden` on a <label> does
   nothing visually (same fix already applied to .auth-page/.app-shell). */
label[hidden] { display: none; }

input,
select {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card-bg);
}

input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

button.primary {
  margin-top: 0.25rem;
  padding: 0.65rem;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button.primary:hover { background: var(--brand-dark); }
button.primary:disabled { opacity: 0.6; cursor: not-allowed; }

button.primary.danger { background: var(--status-critical); }
button.primary.danger:hover { background: #b91c1c; }

button.secondary {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

button.secondary:hover { background: var(--bg); }

.error {
  margin-top: 1rem;
  margin-bottom: 0;
  padding: 0.6rem 0.75rem;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: 8px;
  font-size: 0.85rem;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ---------- App shell (sidebar + topbar + pages) ---------- */

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

.app-shell[hidden] { display: none; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-toggle-btn {
  position: fixed;
  top: 1.5rem;
  left: 240px;
  transform: translateX(-50%);
  z-index: 40;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  transition: left 0.15s ease;
}

.sidebar-toggle-btn:hover { color: var(--text); border-color: var(--brand); }

.app-shell.sidebar-collapsed .sidebar { display: none; }
.app-shell.sidebar-collapsed .sidebar-toggle-btn { left: 0.9rem; transform: none; }

@media (max-width: 720px) {
  .sidebar-toggle-btn { display: none; }
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.sidebar-brand {
  font-size: 1.05rem;
  font-weight: 700;
}

.sidebar-brand span {
  font-weight: 400;
  color: var(--muted);
}

.theme-toggle-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle-btn:hover { color: var(--text); border-color: var(--brand); }

.theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-icon-moon { display: block; }
}

.sidebar-org {
  margin-bottom: 0.5rem;
}

.sidebar-org-name {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-org-plan {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: capitalize;
  margin-top: 0.05rem;
}

.sidebar-logout-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-logout-icon:hover { background: var(--bg); color: var(--status-critical); border-color: var(--status-critical); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.35rem;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: capitalize;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding: 0.7rem 0.7rem 0.15rem;
  cursor: pointer;
}

.nav-section-toggle:hover { color: var(--text); }

.nav-section-arrow {
  font-size: 0.65rem;
  transition: transform 0.15s ease;
}

.nav-section-arrow.collapsed { transform: rotate(-90deg); }

.nav-section-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-group[hidden] { display: none; }

/* Reports used to cap at 240px with its own nested scrollbar; with 11+
   compliance types the sidebar became a scroll-within-a-scroll and most
   report links were hidden. It now just flows in the single scrollable
   .sidebar-nav like every other section, so the whole menu is one
   continuous, fully reachable scroll. */

.nav-item {
  text-align: left;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover { background: var(--bg); color: var(--text); }

.nav-item.active {
  background: var(--brand);
  color: white;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0.2rem;
  margin: -0.2rem;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.sidebar-user-btn:hover { background: var(--bg); }

.sidebar-user-info { min-width: 0; flex: 1; }

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: capitalize;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2.25rem 3rem;
}

.page { display: none; }
.page.active { display: block; }

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header .page-title { margin: 0; }
.page-header-btn { margin-top: 0; white-space: nowrap; }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.page-header-actions button { margin-top: 0; white-space: nowrap; }

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.export-bar:empty { display: none; }

.export-btn {
  width: auto;
  margin-top: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* ---------- Stat tiles ---------- */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  grid-auto-rows: 1fr;
  gap: 1rem;
  max-width: 960px;
  margin-bottom: 1.75rem;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.stat-tile:hover { border-color: var(--brand); }
.stat-tile:disabled { cursor: default; }
.stat-tile:disabled:hover { border-color: var(--border); }

.stat-tile-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.stat-tile.warning .stat-tile-icon { color: var(--status-warning); }
.stat-tile.critical .stat-tile-icon { color: var(--status-critical); }
.stat-tile.good .stat-tile-icon { color: var(--status-good); }

.stat-tile-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-tile-value {
  font-size: 1.8rem;
  font-weight: 600;
  margin-top: auto;
  padding-top: 0.3rem;
}

.stat-tile.warning .stat-tile-value { color: var(--status-warning); }
.stat-tile.critical .stat-tile-value { color: var(--status-critical); }
.stat-tile.good .stat-tile-value { color: var(--status-good); }

/* ---------- Dashboard compliance bar chart ---------- */

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  max-width: 720px;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chart-card-header .section-title { margin: 0; }

.chart-legend {
  display: flex;
  gap: 0.9rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.chart-legend-item { display: flex; align-items: center; gap: 0.35rem; }

.chart-legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.chart-legend-swatch.good { background: var(--status-good); }
.chart-legend-swatch.warning { background: var(--status-warning); }
.chart-legend-swatch.critical { background: var(--status-critical); }

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 32px;
  align-items: center;
  gap: 0.75rem;
  border: none;
  background: transparent;
  padding: 0.2rem 0;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.bar-row-label {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 20px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  display: block;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s ease;
}

.bar-fill.good { background: var(--status-good); }
.bar-fill.warning { background: var(--status-warning); }
.bar-fill.critical { background: var(--status-critical); }

.bar-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* ---------- Team ---------- */

.team-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.team-row:last-child { border-bottom: none; }

.team-row-info { flex: 1; min-width: 0; }
.team-row-name { font-weight: 600; font-size: 0.9rem; }
.team-row-meta {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: capitalize;
}

.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: capitalize;
}

.status-badge.active { background: var(--status-good-bg); color: #166534; }
.status-badge.disabled { background: var(--status-critical-bg); color: #991b1b; }

.team-row-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.team-row-toggle:hover { background: var(--bg); }
.team-row-toggle:disabled { opacity: 0.4; cursor: not-allowed; }

.team-role-select {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  text-transform: capitalize;
}

.team-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Clients ---------- */

.clients-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.client-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.client-row:last-child { border-bottom: none; }

.client-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.client-row-name { font-weight: 600; font-size: 0.9rem; }

.client-balance {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.client-balance.pending { color: var(--status-critical); }
.client-balance.paid-up { color: var(--status-good); }

.client-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.client-ledger {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.client-ledger[hidden] { display: none; }

.badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  font-size: 0.9rem !important;
  color: var(--text) !important;
}

.checkbox-label input { width: auto; }

.conditional-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-left: 1.5rem;
  border-left: 2px solid var(--border);
}

.conditional-fields[hidden] { display: none; }

.clients-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Compliance dashboard ---------- */

.compliance-summary {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 720px;
}

.compliance-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.compliance-item-row:last-child { border-bottom: none; }

.compliance-item-meta { color: var(--muted); font-size: 0.75rem; }

.compliance-item-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h2 { font-size: 1.05rem; margin: 0; }

.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.modal-close:hover { color: var(--text); }

.modal-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.5rem 0 -0.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.fee-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ---------- Landscape form (Add/Edit client) ---------- */

.modal.modal-xwide { max-width: 880px; }

.form-grid.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1.5rem;
  align-items: start;
}

/* Elements that should span the full form width rather than sit in one column. */
.form-grid .checkbox-label,
.form-grid .conditional-fields,
.form-grid .modal-subtitle,
.form-grid .fee-grid,
.form-grid .cl-documents-list,
.form-grid #cl-add-document,
.form-grid > button[type='submit'] {
  grid-column: 1 / -1;
}

.cl-documents-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cl-document-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cl-document-row input[type='text'] { flex: 1; }
.cl-document-row input[type='date'] { width: 160px; }

.password-field-row { display: flex; gap: 0.5rem; }
.password-field-row input { flex: 1; min-width: 0; }

.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.icon-btn:hover { background: var(--bg); }

/* ---------- Voucher (Receipt / Payment) entry ---------- */

.modal.modal-wide { max-width: 720px; }

.voucher-top {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  align-items: flex-end;
}

.voucher-mode-label,
.voucher-date-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
}

.voucher-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

.voucher-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
}

.voucher-table td {
  padding: 0.4rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.voucher-col-num { width: 24px; color: var(--muted); font-size: 0.85rem; padding-top: 0.7rem !important; }
.voucher-col-amount { width: 100px; }
.voucher-col-delete { width: 32px; }

.voucher-table input {
  padding: 0.5rem 0.6rem;
  font-size: 0.88rem;
  width: 100%;
}

.voucher-account-cell { position: relative; }

.voucher-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin: 2px 0 0;
  padding: 0.3rem 0;
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  max-height: 180px;
  overflow-y: auto;
}

.voucher-suggestions[hidden] { display: none; }

.voucher-suggestions li {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.voucher-suggestions li:hover { background: var(--bg); }

.voucher-salary-staff {
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text);
}

.voucher-row-delete {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.5rem 0.3rem;
}

.voucher-row-delete:hover { color: var(--status-critical); }

.voucher-total-label { text-align: right; font-weight: 600; font-size: 0.85rem; }
.voucher-total-value { font-weight: 700; color: var(--status-good); }

.voucher-add-row-btn {
  border: none;
  background: transparent;
  color: var(--status-good);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem 0;
  margin-bottom: 1.25rem;
}

.voucher-add-row-btn:hover { text-decoration: underline; }

#voucher-save { width: 100%; margin-top: 1rem; }

.client-ledger-back { color: var(--muted); margin-bottom: 1.5rem; }
.client-ledger-back:hover { color: var(--brand); }

#client-ledger-balance { font-size: 1.6rem; font-weight: 600; margin-bottom: 1.5rem; }

/* ---------- Reports ---------- */

.report-menu-overview { font-weight: 600; }

.report-category { display: flex; flex-direction: column; }

.report-category-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}

.report-category-toggle:hover { background: var(--bg); color: var(--text); }

.report-category-arrow {
  font-size: 0.6rem;
  transition: transform 0.15s ease;
}

.report-category-arrow.collapsed { transform: rotate(-90deg); }

.report-category-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-left: 0.75rem;
}

.report-category-list[hidden] { display: none; }

.report-menu-item {
  text-align: left;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}

.report-menu-item:hover { background: var(--bg); color: var(--text); }

.report-menu-item.active {
  background: var(--brand);
  color: white;
}

.report-panel {
  min-width: 0;
}

.report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.report-filters label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 160px;
}

/* ---------- Accounts / ledgers ---------- */

.ledger-columns {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.ledger-card {
  flex: 1;
  min-width: 280px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.ledger-balance {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 360px;
  overflow-y: auto;
}

.transaction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.transaction-row:last-child { border-bottom: none; }

.transaction-meta { color: var(--muted); font-size: 0.75rem; }

.transaction-amount.credit { color: var(--status-good); font-weight: 600; }

.report-table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 420px;
  overflow-y: auto;
}

.report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.report-row:last-child { border-bottom: none; }
.report-row-meta { color: var(--muted); font-size: 0.75rem; }

.report-row-clickable {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.report-row-clickable:hover { color: var(--brand); }

.attendance-status-card {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
}

.attendance-status-text {
  font-size: 0.95rem;
  font-weight: 600;
}

.attendance-actions {
  display: flex;
  gap: 0.75rem;
}

.attendance-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.attendance-row:last-child { border-bottom: none; }
.attendance-row-info { flex: 1; min-width: 0; }
.attendance-row-meta { color: var(--muted); font-size: 0.75rem; }

.attendance-selfie-thumb {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}

.attendance-map-link { font-size: 0.75rem; }

.attendance-salary-payable {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
}

.attendance-late { color: var(--status-warning); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  max-width: 820px;
  margin-bottom: 1.5rem;
}

.calendar-day-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 0.4rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.calendar-day:hover { border-color: var(--brand); }
.calendar-day.empty { visibility: hidden; cursor: default; }
.calendar-day.has-items { border-color: var(--status-warning); }
.calendar-day.has-overdue { border-color: var(--status-critical); }

.calendar-day-number { font-size: 0.8rem; font-weight: 600; }
.calendar-day-count { font-size: 0.7rem; color: var(--muted); }

.transaction-amount.debit { color: var(--status-critical); font-weight: 600; }

.payment-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 900px;
}

.payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.payment-row:last-child { border-bottom: none; }

.payment-row-voucher {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

.payment-row-meta { color: var(--muted); font-size: 0.75rem; }

.payment-row-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ---------- Settings ---------- */

.settings-card { max-width: 420px; margin-bottom: 1.5rem; }
.settings-card-wide { max-width: 640px; }

.settings-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.settings-hint-inline {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.78rem;
}

.settings-status {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
}

.settings-status.set { color: var(--status-good); }
.settings-status.unset { color: var(--status-warning); }

.compliance-types-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  max-width: 720px;
}

.compliance-edit-row select,
.compliance-edit-row input[type='number'] {
  flex: 0 0 auto;
  width: auto;
  min-width: 90px;
}

.compliance-type-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.compliance-type-row:last-child { border-bottom: none; }

.compliance-type-row-info { flex: 1; min-width: 0; }
.compliance-type-row-label { font-weight: 600; font-size: 0.9rem; }
.compliance-type-row-key {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
}

.builtin-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

@media (max-width: 720px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 1rem;
    flex-wrap: wrap;
  }
  .sidebar-brand-row { margin-bottom: 0; margin-right: 1.5rem; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; width: 100%; order: 1; }
  .nav-section-toggle { width: auto; padding: 0.55rem 0.5rem 0.15rem; }
  .nav-section-group { flex-direction: row; }
  .nav-section-group[hidden] { display: flex; } /* keep Master items reachable on mobile even when collapsed */
  .sidebar-footer { margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; order: 2; }
  .sidebar-org { display: none; }
  .sidebar-user .avatar,
  .sidebar-user .sidebar-user-info { display: none; } /* keep just the logout icon reachable on mobile */
  .app-shell { flex-direction: column; }
  .main { padding: 1.5rem; }
}

/* ---------- Tasks (general office work board) ---------- */

.task-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}

.task-column {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  min-width: 0;
}

.task-column-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
}

.task-column-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.task-column-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.task-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.task-card-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  white-space: pre-wrap;
}

.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.task-freq-badge {
  font-weight: 600;
  color: var(--brand);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

.task-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.task-stage-select {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .task-board { grid-template-columns: 1fr; }
}

/* ---------- Check-in reminder banner (Dashboard) ---------- */

.checkin-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--status-warning-bg);
  border: 1px solid var(--status-warning);
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.checkin-banner button.primary {
  margin-top: 0;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
}

/* ---------- Bulk actions (Compliance page + Fees Pending) ---------- */

.bulk-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.bulk-select-all {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.bulk-count { color: var(--muted); }

.bulk-actions-bar button.secondary {
  width: auto;
  margin-top: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.report-row-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* Dark theme applies when the OS prefers it (unless the user explicitly
   picked light via the toggle button) OR when the user explicitly picked
   dark — see the theme-toggle-btn wiring in app.js, which sets
   data-theme on <html> and persists it to localStorage. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --card-bg: #1a1d23;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #2a2e37;
    --error-bg: #2a1416;
    --error-text: #f87171;
    --status-good: #0ca30c;
    --status-good-bg: #14532d;
    --status-warning: #fab219;
    --status-warning-bg: #422006;
    --status-critical: #e66767;
    --status-critical-bg: #450a0a;
  }

  :root:not([data-theme="light"]) .status-badge.active { color: #86efac; }
  :root:not([data-theme="light"]) .status-badge.disabled { color: #fca5a5; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --card-bg: #1a1d23;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --border: #2a2e37;
  --error-bg: #2a1416;
  --error-text: #f87171;
  --status-good: #0ca30c;
  --status-good-bg: #14532d;
  --status-warning: #fab219;
  --status-warning-bg: #422006;
  --status-critical: #e66767;
  --status-critical-bg: #450a0a;
}

:root[data-theme="dark"] .status-badge.active { color: #86efac; }
:root[data-theme="dark"] .status-badge.disabled { color: #fca5a5; }
