/* ============================================================
   Gundecha Montego AMS — Stylesheet (Mobile-First Responsive)
   ============================================================ */

:root {
  --primary:       #1e3a5f;
  --primary-light: #2d5a9e;
  --primary-dark:  #142742;
  --accent:        #f59e0b;
  --accent-dark:   #d97706;
  --success:       #10b981;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --info:          #3b82f6;
  --muted:         #6b7280;
  --bg:            #f0f4f8;
  --surface:       #ffffff;
  --surface2:      #f8fafc;
  --border:        #e2e8f0;
  --text:          #1a202c;
  --text-light:    #718096;
  --sidebar-w:     240px;
  --topbar-h:      56px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ─── Topbar ──────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--topbar-h);
  background: var(--primary);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }

/* Hamburger */
.hamburger {
  background: none; border: none; cursor: pointer;
  color: white; font-size: 20px; padding: 6px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background .2s;
  -webkit-tap-highlight-color: transparent;
}
.hamburger:hover { background: rgba(255,255,255,.15); }

.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; flex-shrink: 0;
}
.brand-name  { color: white; font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand-sub   { color: rgba(255,255,255,.6); font-size: 10px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* User dropdown */
.topbar-user {
  position: relative; display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 5px 8px; border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.topbar-user:hover { background: rgba(255,255,255,.1); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-info { display: none; }
.user-name  { display: block; color: white; font-size: 13px; font-weight: 600; }
.user-role-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 20px;
  background: rgba(255,255,255,.15); color: rgba(255,255,255,.8);
  text-transform: capitalize; display: block;
}
.user-dropdown {
  display: none; position: absolute; top: 48px; right: 0;
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 180px; padding: 8px 0;
  z-index: 999;
}
.topbar-user:hover .user-dropdown { display: block; }
.user-dropdown a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: var(--text); text-decoration: none; font-size: 13px;
}
.user-dropdown a:hover { background: var(--bg); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ─── Layout ──────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ─── Sidebar Overlay (mobile) ────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 998;
}
.sidebar-overlay.active { display: block; }

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
  overflow-y: auto; overflow-x: hidden;
  z-index: 999;
  transform: translateX(-100%);
  transition: transform .3s ease;
  -webkit-overflow-scrolling: touch;
}
.sidebar.open { transform: translateX(0); }

.sidebar-nav { padding: 12px 0 60px; }
.nav-section-label {
  padding: 12px 20px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
  color: rgba(255,255,255,.35);
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px; color: rgba(255,255,255,.75);
  text-decoration: none; font-size: 14px; transition: all .2s;
  border-left: 3px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover, .nav-item:active { background: rgba(255,255,255,.1); color: white; }
.nav-item.active { background: rgba(255,255,255,.12); color: white; border-left-color: var(--accent); }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 0;
  padding: 20px 16px;
  min-height: calc(100vh - var(--topbar-h));
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* ─── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.page-header h1 {
  font-size: 1.3rem; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; gap: .5rem; margin: 0;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--primary); }
.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.page-header-actions, .page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ─── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.card-header h3, .card-title {
  font-size: 15px; font-weight: 700; color: var(--primary); margin: 0;
  display: flex; align-items: center; gap: 7px;
}
.card-body { padding: 16px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* ─── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  border-left: 4px solid var(--primary);
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 20px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Tables ──────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--primary); color: white;
  padding: 11px 14px; text-align: left;
  font-size: 12px; font-weight: 600; letter-spacing: .4px; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 11px 14px; font-size: 13px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* Mobile card-style rows */
@media (max-width: 600px) {
  .table-cards thead { display: none; }
  .table-cards tbody tr {
    display: block; padding: 12px; margin-bottom: 10px;
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow); border: none;
  }
  .table-cards tbody td {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px;
  }
  .table-cards tbody td:last-child { border-bottom: none; padding-bottom: 0; }
  .table-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--muted); font-size: 11px; flex-shrink: 0; margin-right: 10px;
  }
}

/* ─── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-muted    { background: #f1f5f9; color: #475569; }
.badge-primary  { background: #dbeafe; color: var(--primary); }
.badge-secondary{ background: #6c757d; color: #fff; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; border: none; text-decoration: none;
  transition: all .2s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover  { background: var(--primary-light); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover  { filter: brightness(1.1); }
.btn-danger  { background: var(--danger);  color: white; }
.btn-danger:hover   { filter: brightness(1.1); }
.btn-warning { background: var(--warning); color: white; }
.btn-outline, .btn-outline-secondary { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover, .btn-outline-secondary:hover { background: var(--bg); }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }
.btn-outline-danger  { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.btn-outline-info    { background: transparent; border: 1.5px solid var(--info); color: var(--info); }
.btn-sm  { padding: 6px 12px; font-size: 12px; }
.btn-xs  { padding: 4px 8px;  font-size: 11px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-label, .form-group label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.form-control {
  padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; background: white;
  transition: border-color .2s, box-shadow .2s; width: 100%;
  -webkit-appearance: none; appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(45,90,158,.1); }
.form-control.error { border-color: var(--danger); }
.form-hint, .text-muted small, small.text-muted { font-size: 11.5px; color: var(--muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.input-group { display: flex; }
.input-group .form-control { border-radius: 8px 0 0 8px; flex: 1; }
.input-group .btn { border-radius: 0 8px 8px 0; }

/* ─── Filters ─────────────────────────────────────────────── */
.filter-card { margin-bottom: 16px; }
.filter-form .filter-row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px;
}
.filter-form .filter-row .form-control { min-width: 120px; flex: 1; }
.filters-bar {
  background: white; padding: 14px 16px;
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
}
.filters-bar .form-group { min-width: 140px; flex: 1; margin-bottom: 0; }

/* ─── Alerts ──────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13.5px;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.close-btn { margin-left: auto; cursor: pointer; background: none; border: none; font-size: 18px; opacity: .6; flex-shrink: 0; }

/* ─── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 5px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.pagination a, .pagination span {
  padding: 7px 12px; border-radius: 6px; font-size: 13px;
  text-decoration: none; color: var(--text); border: 1.5px solid var(--border);
}
.pagination a:hover { background: var(--primary); color: white; border-color: var(--primary); }
.pagination .current { background: var(--primary); color: white; border-color: var(--primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 2000; align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white; border-radius: 14px 14px 0 0;
  box-shadow: var(--shadow-lg); width: 100%; max-height: 92vh;
  overflow-y: auto; animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ─── Invoice / Receipt ───────────────────────────────────── */
.invoice-wrapper {
  max-width: 760px; margin: 0 auto;
  background: white; padding: 24px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.invoice-society-name { font-size: 18px; font-weight: 800; color: var(--primary); }
.invoice-society-address { font-size: 12px; color: var(--muted); margin-top: 4px; }
.invoice-no { font-size: 18px; font-weight: 700; color: var(--accent); }
.invoice-divider { border: none; border-top: 2px solid var(--primary); margin: 14px 0; }
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.invoice-meta-label { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.invoice-meta-value { font-size: 13px; font-weight: 600; color: var(--text); }
.invoice-total-row { background: var(--primary); color: white; font-weight: 700; }
.invoice-total-row td { padding: 12px 14px !important; font-size: 14px; }

/* ─── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab-btn {
  padding: 10px 16px; border: none; background: none;
  font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s;
  white-space: nowrap;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Utility ─────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.flex   { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2  { gap: 8px; }
.mt-1   { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1   { margin-bottom: 8px; } .mb-3 { margin-bottom: 24px; }
.p-3    { padding: 1rem !important; }
.py-4   { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.ml-1   { margin-left: .25rem; }
.text-right  { text-align: right; } .text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.text-danger { color: var(--danger) !important; }
.text-success{ color: #16a34a !important; }
.text-warning{ color: #d97706 !important; }
.font-bold   { font-weight: 700; }
.w-100  { width: 100%; }
.d-none { display: none; }
.table-borderless td, .table-borderless th { border: none !important; padding: .35rem .5rem; }
code { background: #f1f3f5; padding: .1rem .35rem; border-radius: 3px; font-size: .85em; }

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 42px; margin-bottom: 12px; opacity: .4; display: block; }
.empty-state p { font-size: 14px; }

/* ─── Login Page ──────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: white; border-radius: 18px; padding: 36px 28px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .brand-icon { width: 60px; height: 60px; font-size: 26px; margin: 0 auto 12px; }
.login-title { font-size: 22px; font-weight: 800; color: var(--primary); text-align: center; }
.login-subtitle { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 24px; }

/* ─── Bottom Nav (mobile only) ────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
  background: white; border-top: 1px solid var(--border);
  padding: 4px 0 env(safe-area-inset-bottom, 4px);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.bottom-nav-items { display: flex; justify-content: space-around; }
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 8px; text-decoration: none; color: var(--muted);
  font-size: 10px; font-weight: 600; flex: 1; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item i { font-size: 18px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active i { color: var(--primary); }

/* Password strength */
#passStrength { margin-top: .35rem; }
.user-profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 1.8rem; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}

/* ─── TABLET  (≥ 640px) ───────────────────────────────────── */
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .invoice-wrapper { padding: 32px 28px; }
  .invoice-society-name { font-size: 20px; }
}

/* ─── DESKTOP (≥ 900px) ───────────────────────────────────── */
@media (min-width: 900px) {
  :root { --topbar-h: 64px; }

  .topbar { padding: 0 24px; }
  .hamburger { display: none; }

  .user-info { display: block; }

  /* Sidebar always visible on desktop */
  .sidebar {
    transform: translateX(0);
    transition: none;
  }
  .sidebar-overlay { display: none !important; }

  .main-content {
    margin-left: var(--sidebar-w);
    padding: 28px;
  }

  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }

  /* Desktop modal centered */
  .modal-overlay { align-items: center; }
  .modal { border-radius: 14px; width: 90%; max-width: 600px; }
  @keyframes slideUp { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

  .invoice-wrapper { padding: 40px; }
  .invoice-society-name { font-size: 22px; }

  .bottom-nav { display: none !important; }
}

/* ─── LARGE DESKTOP (≥ 1200px) ───────────────────────────── */
@media (min-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(5, 1fr); }
  .main-content { padding: 32px; }
}

/* ─── Mobile tweaks ───────────────────────────────────────── */
@media (max-width: 899px) {
  .main-content { padding-bottom: 80px; } /* space for bottom nav */
  .bottom-nav { display: block; }
  .stat-value { font-size: 17px; }
  .page-header h1 { font-size: 1.15rem; }
  .card-body { padding: 14px; }
  thead th { padding: 10px 12px; font-size: 11px; }
  tbody td { padding: 10px 12px; font-size: 12.5px; }
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 11.5px; }
  .filter-form .filter-row { padding: 10px 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 16px; }
  .stat-value { font-size: 16px; }
  .invoice-meta { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }
}

/* ─── Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .bottom-nav, .page-header .btn,
  .filters-bar, .pagination, .no-print { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .invoice-wrapper { box-shadow: none; padding: 0; }
}

/* ─── Flat Owner Grid ─────────────────────────────────────── */
.flat-owner-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) {
  .flat-owner-grid { grid-template-columns: 1fr 1.4fr; gap: 20px; }
}

/* ─── Stat cards: always fit content, never overflow ─────── */
.stat-card {
  min-width: 0;        /* allow shrinking */
  overflow: hidden;
}
.stat-info {
  min-width: 0;
  overflow: hidden;
}
.stat-value {
  font-size: clamp(13px, 2.5vw, 22px);
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  display: block;
}
.stat-label {
  font-size: clamp(9px, 1.5vw, 12px);
  white-space: normal;
  line-height: 1.3;
}
.stat-icon {
  flex-shrink: 0;  /* never shrink the icon */
}

/* ─── Stats grid: responsive without inline overrides ─────── */
.stats-grid {
  grid-template-columns: repeat(2, 1fr) !important;
}
@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (min-width: 900px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr) !important; }
}
@media (min-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(5, 1fr) !important; }
}

/* ─── Dashboard 2-col sections ───────────────────────────── */
.dashboard-2col { grid-template-columns: 1fr !important; }
@media (min-width: 900px) {
  .dashboard-chart-row { grid-template-columns: 1.6fr 1fr !important; }
  .dashboard-bottom-row { grid-template-columns: 1fr 1fr !important; }
}

/* ─── Fix ALL inline grid overrides for mobile ───────────── */
@media (max-width: 640px) {
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
@media (min-width: 641px) and (max-width: 899px) {
  [style*="grid-template-columns:repeat(4"] { grid-template-columns: repeat(2,1fr) !important; }
  [style*="grid-template-columns:repeat(5"] { grid-template-columns: repeat(3,1fr) !important; }
  [style*="grid-template-columns:1fr 1."]   { grid-template-columns: 1fr !important; }
}

/* ─── Bottom nav: desktop hidden ─────────────────────────── */
@media (min-width: 900px) {
  .bottom-nav { display: none !important; }
  .main-content { padding-bottom: 28px; }
}

/* ─── Tables: scroll on mobile ───────────────────────────── */
.card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card { overflow: visible; }

/* ─── General mobile fixes ───────────────────────────────── */
@media (max-width: 899px) {
  .main-content { padding-bottom: 76px; }
}

@media (max-width: 480px) {
  .stat-card { padding: 10px 12px; gap: 8px; }
  .stat-icon { width: 36px; height: 36px; font-size: 15px; border-radius: 8px; }
  .brand-sub { display: none; }
  .invoice-wrapper { padding: 16px 12px; }
  .invoice-head { flex-direction: column; }
  .invoice-head > div:last-child { text-align: left !important; }
  .page-actions, .page-header-actions { flex-direction: column; width: 100%; }
  .page-actions .btn, .page-header-actions .btn { width: 100%; justify-content: center; }
  .filter-form .filter-row { flex-direction: column; }
  .filter-form .filter-row .form-control, .filter-form .filter-row .btn { width: 100%; }
}

/* ─── Password strength ───────────────────────────────────── */
#passStrength { margin-top: .35rem; }
.user-profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 1.8rem; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
}

/* Settings charge rules responsive grid */
@media (max-width: 768px) {
  [style*="grid-template-columns:2fr 1fr 1fr 1fr auto"] {
    grid-template-columns: 1fr 1fr !important;
  }
}
