/* ============================================================
   DMS — Pakistan Association of the Blind
   Main Stylesheet: RTL, Urdu, Noto Nastaliq, Accessible
   ============================================================ */

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

/* ─── CSS Variables ────────────────────────────────────────── */
:root {
  --clr-primary:       #1a3a8a;
  --clr-primary-dark:  #102566;
  --clr-primary-light: #2d56c4;
  --clr-accent:        #c8922a;
  --clr-accent-light:  #f5d78e;
  --clr-danger:        #c0392b;
  --clr-success:       #1a7a4a;
  --clr-warning:       #c8922a;
  --clr-reversed:      #7f3c3c;

  --clr-bg:            #f4f6fb;
  --clr-surface:       #ffffff;
  --clr-border:        #d4daf0;
  --clr-border-light:  #e8ecf8;
  --clr-text:          #1e2a4a;
  --clr-text-muted:    #5a6a8a;
  --clr-text-light:    #8a9bba;

  --sidebar-w:         260px;
  --header-h:          68px;
  --radius-sm:         6px;
  --radius-md:         10px;
  --radius-lg:         16px;
  --radius-xl:         24px;

  --shadow-sm:         0 1px 3px rgba(26,58,138,.08);
  --shadow-md:         0 4px 16px rgba(26,58,138,.12);
  --shadow-lg:         0 8px 32px rgba(26,58,138,.16);

  --font-urdu:         'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif;
  --font-num:          'Arial', sans-serif; /* English digits */
  --transition:        0.2s ease;
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-urdu);
  direction: rtl;
  text-align: right;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.8;
  display: block;
  min-height: 100vh;
  overflow-x: hidden;
}

/* English digits stay in English font */
[dir="rtl"] .num,
[dir="rtl"] .amount,
[dir="rtl"] td.num,
[dir="rtl"] span.num {
  font-family: var(--font-num);
  direction: ltr;
  display: inline-block;
}

/* ─── Accessibility ─────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.sr-only-focusable:focus {
  position: fixed; top: 10px; right: 10px; z-index: 9999;
  padding: 8px 16px; background: var(--clr-primary);
  color: #fff; border-radius: var(--radius-sm);
  width: auto; height: auto; clip: auto;
}

:focus-visible {
  outline: 3px solid var(--clr-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh; /* dynamic viewport — accounts for mobile browser chrome */
  background: var(--clr-primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo { color: var(--clr-accent-light); flex-shrink: 0; }

.sidebar-org {
  display: flex;
  flex-direction: column;
}

.sidebar-org-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.5;
}

.sidebar-org-branch {
  font-size: 0.72rem;
  color: var(--clr-accent-light);
}

/* Nav list */
.nav-list {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.nav-item.active {
  background: var(--clr-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(200,146,42,.4);
}

.nav-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

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

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.user-role {
  font-size: 0.65rem;
  color: var(--clr-accent-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.user-name {
  font-size: 0.8rem;
  color: #fff;
}

.btn-logout {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.75);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  flex-shrink: 0;
}

.btn-logout:hover { background: var(--clr-danger); color: #fff; }

/* ─── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-right: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}

/* Page Header */
.page-header {
  background: var(--clr-surface);
  border-bottom: 2px solid var(--clr-border-light);
  padding: 0 28px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.page-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--clr-primary);
}

.page-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Content Area */
.content-area {
  padding: 24px 28px;
  flex: 1;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--clr-border-light);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--clr-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--clr-primary);
}

.card-body {
  padding: 20px 22px;
}

/* ─── Metric Cards ──────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--clr-surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--clr-border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.metric-icon svg { width: 24px; height: 24px; }

@media (max-width: 767px) {
  .metrics-grid .metric-card:not(:last-child) .metric-icon {
    width: 36px;
    height: 36px;
  }
  .metrics-grid .metric-card:not(:last-child) .metric-icon svg {
    width: 18px;
    height: 18px;
  }
  .metrics-grid .metric-card:not(:last-child) .metric-value {
    font-size: 1.2rem;
  }
  .metrics-grid .metric-card:not(:last-child) .metric-label {
    font-size: 0.72rem;
  }
  .metrics-grid .metric-card:not(:last-child) {
    padding: 14px;
    gap: 10px;
  }
}

.metric-icon.blue   { background: rgba(26,58,138,.1);  color: var(--clr-primary); }
.metric-icon.gold   { background: rgba(200,146,42,.1); color: var(--clr-accent); }
.metric-icon.green  { background: rgba(26,122,74,.1);  color: var(--clr-success); }

.metric-body { flex: 1; }

.metric-label {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-num);
  color: var(--clr-primary);
  line-height: 1.2;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-urdu);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--clr-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,58,138,.3);
}
.btn-primary:hover { background: var(--clr-primary-light); }

.btn-accent {
  background: var(--clr-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(200,146,42,.3);
}
.btn-accent:hover { background: #b07a20; }

.btn-success {
  background: var(--clr-success);
  color: #fff;
}
.btn-success:hover { background: #145c37; }

.btn-danger {
  background: var(--clr-danger);
  color: #fff;
}
.btn-danger:hover { background: #922b21; }

.btn-outline {
  background: transparent;
  color: var(--clr-primary);
  border: 2px solid var(--clr-border);
}
.btn-outline:hover {
  border-color: var(--clr-primary);
  background: rgba(26,58,138,.05);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── Forms ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  margin-bottom: 6px;
}

label .required { color: var(--clr-danger); margin-right: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-urdu);
  font-size: 0.9rem;
  color: var(--clr-text);
  background: var(--clr-surface);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
  direction: rtl;
}

.form-control:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(26,58,138,.12);
}

.form-control::placeholder { color: var(--clr-text-light); }

/* Number inputs keep ltr */
input[type="number"],
input[type="date"],
.num-input {
  direction: ltr;
  text-align: left;
  font-family: var(--font-num);
}

select.form-control { cursor: pointer; }

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

.form-error {
  font-size: 0.78rem;
  color: var(--clr-danger);
  margin-top: 4px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  margin-top: 4px;
}

/* Radio group */
.radio-group {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--clr-text);
}

.radio-label input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--clr-primary);
  cursor: pointer;
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }

/* ─── Tables ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead { background: var(--clr-bg); }

th {
  padding: 12px 14px;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  border-bottom: 2px solid var(--clr-border-light);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--clr-border-light);
  color: var(--clr-text);
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(26,58,138,.025); }

/* Numeric table cells */
td.num-col {
  font-family: var(--font-num);
  direction: ltr;
  text-align: left;
  font-weight: 600;
}

/* ─── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-success  { background: rgba(26,122,74,.1);   color: var(--clr-success); }
.badge-danger   { background: rgba(192,57,43,.1);   color: var(--clr-danger);  }
.badge-warning  { background: rgba(200,146,42,.1);  color: var(--clr-accent);  }
.badge-primary  { background: rgba(26,58,138,.1);   color: var(--clr-primary); }
.badge-reversed { background: rgba(127,60,60,.1);   color: var(--clr-reversed);}

/* ─── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(16,37,102,.55);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--clr-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(.97);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--clr-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-primary);
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--clr-bg);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--clr-text-muted);
  transition: background var(--transition);
}

.modal-close:hover { background: var(--clr-danger); color: #fff; }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--clr-border-light);
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

/* ─── Search / Filter Bar ───────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 16px 0;
}

.filter-bar .form-control { flex: 1; min-width: 180px; }

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

.search-input-wrap svg {
  position: absolute;
  top: 50%; left: 12px;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--clr-text-light);
  pointer-events: none;
}

.search-input-wrap .form-control { padding-left: 38px; }

/* ─── Alert / Flash ─────────────────────────────────────────── */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-right: 4px solid transparent;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

.alert-success {
  background: rgba(26,122,74,.08);
  color: var(--clr-success);
  border-right-color: var(--clr-success);
}

.alert-danger {
  background: rgba(192,57,43,.08);
  color: var(--clr-danger);
  border-right-color: var(--clr-danger);
}

.alert-warning {
  background: rgba(200,146,42,.08);
  color: var(--clr-accent);
  border-right-color: var(--clr-accent);
}

/* ─── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
  flex-wrap: wrap;
}

.page-btn {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  cursor: pointer;
  font-family: var(--font-num);
  font-size: 0.85rem;
  transition: all var(--transition);
  text-decoration: none;
}

.page-btn:hover { border-color: var(--clr-primary); color: var(--clr-primary); }
.page-btn.active { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Charts ─────────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-wrap { position: relative; padding: 8px 0; }
.chart-wrap canvas { max-height: 260px; }

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 767px) {
  .insights-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.insight-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insight-label { font-size: 0.75rem; color: var(--clr-text-muted); font-weight: 600; }
.insight-value { font-family: var(--font-num); font-size: 1.1rem; font-weight: 700; color: var(--clr-primary); }
.insight-sub   { font-size: 0.75rem; color: var(--clr-text-light); }

/* ─── Profile ────────────────────────────────────────────────── */
.profile-header {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-primary-light));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 28px;
  color: #fff;
}

.profile-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
  border: 3px solid rgba(255,255,255,.4);
}

.profile-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }

.profile-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.profile-tag {
  padding: 3px 12px;
  background: rgba(255,255,255,.2);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ─── HTMX Indicator ────────────────────────────────────────── */
.htmx-indicator {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: var(--clr-primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 999;
  align-items: center;
  gap: 10px;
}

.htmx-request .htmx-indicator { display: flex; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--clr-text-muted);
}

.empty-state svg {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  color: var(--clr-border);
}

.empty-state h3 { font-size: 1rem; margin-bottom: 6px; color: var(--clr-text); }
.empty-state p  { font-size: 0.85rem; }

/* ─── Date Filter ────────────────────────────────────────────── */
.date-filter-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--clr-surface);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--clr-border-light);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.date-filter-row .form-group { margin-bottom: 0; flex: 1; min-width: 150px; }

/* ─── Receipt Specific ───────────────────────────────────────── */
.receipt-page-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  /* Receipt layout */
  .receipt-page-wrap {
    grid-template-columns: 1fr !important;
    overflow: hidden !important;
  }
}

/* ─── Login Page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--clr-primary-dark) 0%, var(--clr-primary) 50%, var(--clr-primary-light) 100%);
  padding: 20px;
}

.login-card {
  background: var(--clr-surface);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo svg { width: 56px; height: 56px; color: var(--clr-primary); }
.login-title { font-size: 1.1rem; font-weight: 700; color: var(--clr-primary); margin-top: 12px; }
.login-sub   { font-size: 0.8rem; color: var(--clr-text-muted); margin-top: 4px; }


/* ─── Responsive ─────────────────────────────────────────────── */

/* ─── Hamburger button — hidden on desktop ──────────────────── */
.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--clr-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background var(--transition);
  margin-left: 8px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-hamburger:hover { background: rgba(26,58,138,.08); }
.btn-hamburger svg {
  width: 26px;
  height: 26px;
  pointer-events: none;
  display: block;
}

/* ─── Sidebar overlay — hidden on desktop ───────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16,37,102,.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}
.sidebar-overlay.overlay-open {
  opacity: 1;
  pointer-events: all;
}

/* ─── Responsive: Tablet (≤ 900px) ──────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 220px; }
  .main-content { margin-right: 220px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ─── Responsive: Mobile (≤ 767px) ──────────────────────────── */
@media (max-width: 767px) {

  /* Show hamburger */
  .btn-hamburger { display: flex; }

  /* Show overlay element */
  .sidebar-overlay { display: block; }

  /* Sidebar: slide off-screen to the RIGHT (RTL layout) */
  .sidebar {
    width: 260px !important;
    transform: translateX(100%) !important;;
    transition: transform 0.28s ease;
    z-index: 100;
    right: 0;
    left: auto;
}

  /* When JS adds this class, slide it in */
  .sidebar.sidebar-open {
    transform: translateX(0) !important;
    box-shadow: -6px 0 30px rgba(0,0,0,.3) !important;
}

  /* Main content fills full width */
  /* Main content fills full width */
  .main-content {
    margin-right: 0 !important;
    overflow-x: hidden;
    width: 100vw;
    max-width: 100vw;
  }

  /* Page header */
  .page-header { padding: 0 12px; }
  .page-header-inner { gap: 8px; }
  .page-title { font-size: 1rem; }
  .page-header-actions { flex-wrap: wrap; gap: 6px; }

  /* Content area */
  .content-area {
    padding: 14px 12px;
    overflow-x: hidden;
    max-width: 100%;
  }

  /* Metrics: 2 columns on mobile, last item full width */
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .metrics-grid .metric-card:last-child { grid-column: span 2; }

  /* Filter bar stacks */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control,
  .search-input-wrap { min-width: unset !important; width: 100%; }

  /* Date filter row stacks */
  .date-filter-row { flex-direction: column; align-items: stretch; }
  .date-filter-row .form-group { min-width: unset; }

/* Modals */
.modal { max-width: calc(100vw - 28px) !important; }
.modal-body, .modal-header, .modal-footer { padding: 14px 16px; }
.modal .form-grid { grid-template-columns: 1fr !important; }
.modal .form-grid .span-2 { grid-column: span 1 !important; }

  /* Profiles page layout fix */
  .profiles-layout { grid-template-columns: 1fr !important; }
  .profile-detail-grid { grid-template-columns: 1fr !important; }
  .donor-list-wrap { max-height: 260px !important; }

  /* Settings page layout fix */
  .settings-layout { grid-template-columns: 1fr !important; }

  /* Card adjustments */
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 14px; }
  .card-header .btn { font-size: 0.8rem; padding: 6px 12px; }

  /* Receipt layout */
  .receipt-page-wrap {
    grid-template-columns: 1fr !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }

  .receipt-scroll-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    display: block;
  }
}

/* ─── Responsive: Small phones (≤ 400px) ────────────────────── */
@media (max-width: 400px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .btn { font-size: 0.8rem; padding: 7px 12px; }
}

/* ─── Touch / Mobile Pointer Fix ────────────────────────────── */
@media (hover: none) and (pointer: coarse) {

  /* Remove hover states that get "stuck" on touch */
  .nav-item:hover,
  .nav-item:focus-visible {
    background: transparent;
    color: rgba(255,255,255,.75);
  }
  .nav-item.active {
    background: var(--clr-accent);
    color: #fff;
  }

  .metric-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }

  .btn:hover { opacity: 1; }
  .btn-primary:hover  { background: var(--clr-primary); }
  .btn-accent:hover   { background: var(--clr-accent); }
  .btn-success:hover  { background: var(--clr-success); }
  .btn-danger:hover   { background: var(--clr-danger); }
  .btn-outline:hover  { background: transparent; border-color: var(--clr-border); }
  .btn-logout:hover   { background: rgba(255,255,255,.1); color: rgba(255,255,255,.75); }
  .modal-close:hover  { background: var(--clr-bg); color: var(--clr-text-muted); }
  .page-btn:hover     { border-color: var(--clr-border); color: var(--clr-text); }
  tr:hover td         { background: transparent; }
}

/* Fix tap highlight and touch response on all clickable elements */
a, button, .btn, .nav-item, .page-btn, .modal-close,
.btn-logout, .btn-hamburger, .autocomplete-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ─── Utility Classes ────────────────────────────────────────── */
.text-muted  { color: var(--clr-text-muted); }
.text-danger { color: var(--clr-danger); }
.text-success{ color: var(--clr-success); }
.text-accent { color: var(--clr-accent); }
.text-small  { font-size: 0.8rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
