/* ================================================================
   ICMS – Church Management System
   Clean Admin UI  |  White sidebar · Light gray body · Green accent
   ================================================================ */

/* ----------------------------------------------------------------
   CSS Custom Properties
   ---------------------------------------------------------------- */
:root {
  /* Brand */
  --green:          #27ae60;
  --green-hover:    #219a52;
  --green-light:    #eafaf1;
  --green-mid:      #a9dfbf;

  /* Layout */
  --sidebar-w:      240px;
  --topbar-h:       64px;

  /* Surface */
  --bg-body:        #f4f6f9;
  --bg-card:        #ffffff;
  --bg-sidebar:     #ffffff;
  --bg-topbar:      #ffffff;

  /* Text */
  --text-dark:      #2c3e50;
  --text-mid:       #5d6d7e;
  --text-muted:     #95a5a6;

  /* Borders & Shadows */
  --border:         #e8ecf0;
  --shadow-sm:      0 1px 4px rgba(0,0,0,.06);
  --shadow:         0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:      0 4px 24px rgba(0,0,0,.10);

  /* Status */
  --success:        #27ae60;
  --info:           #2980b9;
  --warning:        #f39c12;
  --danger:         #e74c3c;
  --secondary:      #95a5a6;

  /* Radius */
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;

  /* Transitions */
  --transition:     0.18s ease;
}

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

html { font-size: 15px; height: 100%; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--green); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--green-hover); }

img { max-width: 100%; }

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.3;
}

/* ----------------------------------------------------------------
   Layout Shell
   ---------------------------------------------------------------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ----------------------------------------------------------------
   Sidebar
   ---------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Logo / Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: var(--green);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-icon svg { width: 20px; height: 20px; fill: #fff; }

.sidebar-brand-text  { line-height: 1.25; display: flex; flex-direction: column; }
.sidebar-brand-title { font-size: .95rem; font-weight: 700; color: var(--text-dark); white-space: nowrap; }
.sidebar-brand-sub   { font-size: .68rem; color: var(--text-muted); font-weight: 400; white-space: normal; line-height: 1.3; }

/* Navigation */
.sidebar-nav { flex: 1; padding: 14px 0; }

.nav-section-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 14px 20px 6px;
}

.nav-item { display: block; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 20px;
  color: var(--text-mid);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
  text-decoration: none;
  white-space: nowrap;
  border-left: 3px solid transparent;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }

.nav-link:hover {
  background: var(--green-light);
  color: var(--green);
  border-left-color: transparent;
}
.nav-link:hover svg { opacity: 1; }

.nav-link.active {
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
  border-left-color: var(--green);
}
.nav-link.active svg { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------
   Main Content Area
   ---------------------------------------------------------------- */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ----------------------------------------------------------------
   Top Bar
   ---------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 7px 16px;
}

.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: .875rem;
  color: var(--text-dark);
  width: 100%;
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--bg-body);
  color: var(--text-mid);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
  text-decoration: none;
}
.topbar-btn:hover { background: var(--green-light); color: var(--green); }
.topbar-btn svg { width: 18px; height: 18px; }

.topbar-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  text-decoration: none;
  color: var(--text-dark);
}
.topbar-user:hover { background: var(--bg-body); color: var(--text-dark); }

.topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.topbar-user-info { line-height: 1.2; }
.topbar-user-name { font-size: .85rem; font-weight: 600; }
.topbar-user-role { font-size: .72rem; color: var(--text-muted); text-transform: capitalize; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-dark);
}
.sidebar-toggle svg { width: 22px; height: 22px; }

/* ----------------------------------------------------------------
   Page Content
   ---------------------------------------------------------------- */
.page-content {
  flex: 1;
  padding: 28px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text-dark); }
.page-subtitle { font-size: .875rem; color: var(--text-muted); margin-top: 2px; }

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

/* ----------------------------------------------------------------
   Stat / KPI Cards (top of dashboard)
   ---------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; }

.stat-icon-green  { background: #eafaf1; color: var(--green); }
.stat-icon-blue   { background: #eaf2fb; color: var(--info); }
.stat-icon-orange { background: #fef9e7; color: var(--warning); }
.stat-icon-red    { background: #fdedec; color: var(--danger); }
.stat-icon-teal   { background: #e8f8f5; color: #1abc9c; }

.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; color: var(--text-dark); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.stat-trend { font-size: .75rem; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-trend-up   { color: var(--success); }
.stat-trend-down { color: var(--danger); }

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

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

.card-title { font-size: 1rem; font-weight: 600; color: var(--text-dark); }
.card-subtitle { font-size: .8rem; color: var(--text-muted); }

.card-body { padding: 22px; }
.card-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--bg-body); }

/* ----------------------------------------------------------------
   Grid helpers
   ---------------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 22px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; }

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

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

thead th {
  background: var(--bg-body);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 11px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--green-light); }

tbody td { padding: 12px 16px; color: var(--text-dark); vertical-align: middle; }

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn svg { width: 16px; height: 16px; }

.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-primary:hover { background: var(--green-hover); border-color: var(--green-hover); color: #fff; }

.btn-outline-primary {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}
.btn-outline-primary:hover { background: var(--green); color: #fff; }

.btn-secondary {
  background: var(--bg-body);
  color: var(--text-mid);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text-dark); }

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

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-outline-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 11px 26px; font-size: 1rem; }

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

/* ----------------------------------------------------------------
   Badges
   ---------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-success   { background: #eafaf1; color: #1e8449; }
.badge-primary   { background: #eaf2fb; color: #1a5276; }
.badge-info      { background: #d6eaf8; color: #154360; }
.badge-warning   { background: #fef9e7; color: #9a7d0a; }
.badge-danger    { background: #fdedec; color: #922b21; }
.badge-secondary { background: #f2f3f4; color: #616a6b; }
.badge-dark      { background: #2c3e50; color: #fff; }

/* ----------------------------------------------------------------
   Forms
   ---------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-dark);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39,174,96,.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--bg-body); color: var(--text-muted); cursor: not-allowed; }

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

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(231,76,60,.12); }

.invalid-feedback { font-size: .78rem; color: var(--danger); margin-top: 4px; }
.form-hint        { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

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

/* Checkboxes / Radio */
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--green);
  cursor: pointer;
}
.form-check-label { font-size: .875rem; color: var(--text-mid); cursor: pointer; }

/* ----------------------------------------------------------------
   Alerts / Flash Messages
   ---------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  border: 1px solid transparent;
  margin-bottom: 20px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-body { flex: 1; }
.alert-dismiss {
  background: none; border: none; cursor: pointer;
  opacity: .5; transition: opacity var(--transition);
}
.alert-dismiss:hover { opacity: 1; }
.alert-dismiss svg { width: 16px; height: 16px; }

.alert-success { background: #eafaf1; color: #1e8449; border-color: var(--green-mid); }
.alert-error,
.alert-danger   { background: #fdedec; color: #922b21; border-color: #f1948a; }
.alert-warning  { background: #fef9e7; color: #9a7d0a; border-color: #f9e79f; }
.alert-info     { background: #eaf2fb; color: #1a5276; border-color: #aed6f1; }

/* ----------------------------------------------------------------
   Search & Filter Bar
   ---------------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-card);
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.filter-search {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}
.filter-search svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.filter-search input {
  border: none; background: transparent; outline: none;
  font-size: .875rem; color: var(--text-dark); width: 100%;
}

.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-dark);
  background: var(--bg-body);
  cursor: pointer;
  outline: none;
}
.filter-select:focus { border-color: var(--green); }

/* ----------------------------------------------------------------
   Pagination
   ---------------------------------------------------------------- */
.pagination { display: flex; align-items: center; gap: 4px; list-style: none; }
.page-link {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-mid);
  background: #fff;
  transition: all var(--transition);
  text-decoration: none;
}
.page-link:hover { background: var(--green-light); color: var(--green); border-color: var(--green); }
.page-item.active .page-link { background: var(--green); color: #fff; border-color: var(--green); }
.page-item.disabled .page-link { opacity: .45; pointer-events: none; }

/* ----------------------------------------------------------------
   Member / Item Photo
   ---------------------------------------------------------------- */
.member-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.member-avatar-lg {
  width: 88px; height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}

.avatar-placeholder {
  background: var(--green-light);
  color: var(--green);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ----------------------------------------------------------------
   Detail / Profile Section
   ---------------------------------------------------------------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px 24px;
}
.detail-item {}
.detail-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 3px; }
.detail-value { font-size: .9rem; color: var(--text-dark); }

/* ----------------------------------------------------------------
   Dashboard-specific
   ---------------------------------------------------------------- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 1rem; font-weight: 600; color: var(--text-dark); }
.section-link  { font-size: .82rem; color: var(--green); font-weight: 500; }

/* Alert items list (low stock, overdue) */
.alert-list { list-style: none; }
.alert-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.alert-list-item:last-child { border-bottom: none; }
.alert-list-name { font-size: .875rem; font-weight: 500; color: var(--text-dark); }
.alert-list-meta { font-size: .78rem; color: var(--text-muted); }
.alert-list-badge { flex-shrink: 0; }

/* Activity feed */
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); flex-shrink: 0; margin-top: 6px;
}
.activity-text { font-size: .85rem; color: var(--text-dark); }
.activity-time { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ----------------------------------------------------------------
   Auth Pages
   ---------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 24px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 40px 36px;
  border: 1px solid var(--border);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  justify-content: center;
}

.auth-logo-icon {
  width: 44px; height: 44px;
  background: var(--green);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.auth-logo-icon svg { width: 24px; height: 24px; fill: #fff; }

.auth-logo-name { font-size: 1.2rem; font-weight: 700; color: var(--text-dark); }

.auth-title    { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-subtitle { font-size: .875rem; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

.auth-divider  { border: none; border-top: 1px solid var(--border); margin: 22px 0; }

/* ----------------------------------------------------------------
   Empty State
   ---------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  background: var(--bg-body);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.empty-state-icon svg { width: 32px; height: 32px; color: var(--text-muted); }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-mid); margin-bottom: 6px; }
.empty-state-text  { font-size: .875rem; }

/* ----------------------------------------------------------------
   Tabs
   ---------------------------------------------------------------- */
.tabs { display: flex; border-bottom: 2px solid var(--border); gap: 0; margin-bottom: 20px; }
.tab-link {
  padding: 10px 20px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab-link:hover { color: var(--green); }
.tab-link.active { color: var(--green); border-bottom-color: var(--green); }

/* ----------------------------------------------------------------
   Modals
   ---------------------------------------------------------------- */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.show { display: flex; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); transition: color var(--transition);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--danger); background: #fdedec; }
.modal-close svg { width: 16px; height: 16px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ----------------------------------------------------------------
   Print
   ---------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .page-actions, .filter-bar, .btn, .pagination { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); --sidebar-w: 240px; }

  .main-wrapper { margin-left: 0; }

  .sidebar-toggle { display: flex; }

  .page-content { padding: 16px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }

  .topbar-search { max-width: 200px; }

  .stat-grid { grid-template-columns: 1fr 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .topbar-search { display: none; }
}

/* ----------------------------------------------------------------
   Utility helpers
   ---------------------------------------------------------------- */
.d-flex      { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-green  { color: var(--green); }
.text-danger { color: var(--danger); }
.text-warning{ color: var(--warning); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm  { font-size: .82rem; }
.fs-xs  { font-size: .75rem; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-0   { padding: 0; }
.w-100 { width: 100%; }
.overflow-hidden { overflow: hidden; }
.no-wrap { white-space: nowrap; }

/* Clickable table rows */
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: var(--hover-bg, rgba(0,0,0,.035)); }
