/* ── Root Variables ──────────────────────────────────────────────────────── */
:root {
  --primary:    #1a56db;
  --primary-dk: #1341b0;
  --accent:     #f59e0b;
  --success:    #16a34a;
  --danger:     #dc2626;
  --info:       #0284c7;
  --bg:         #f5f7fb;
  --sidebar-bg: #1e2a3b;
  --sidebar-w:  240px;
  --navbar-h:   60px;
  --border:     #e2e8f0;
  --text-muted: #64748b;
  --font-body:  'DM Sans', sans-serif;
  --font-display: 'Playfair Display', serif;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
  --radius:     10px;
}

/* ── Global ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: #1e293b;
  margin: 0;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-wrapper { background: linear-gradient(135deg, #1e2a3b 0%, #1a56db 100%); }
.auth-card { border-radius: var(--radius); border: none; }

/* ── Top Navbar ──────────────────────────────────────────────────────────── */
.top-navbar {
  height: var(--navbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1030;
  padding: 0 1rem;
  box-shadow: var(--shadow);
}
.navbar-brand-text { font-size: 1rem; font-weight: 600; color: #1e293b; }
.sidebar-toggle {
  color: #64748b;
  font-size: 1.1rem;
  padding: 0.4rem 0.6rem;
  border: none !important;
}
.sidebar-toggle:hover { color: var(--primary); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.layout-wrapper {
  display: flex;
  padding-top: var(--navbar-h);
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: var(--navbar-h);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 1020;
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.2rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.logo-text strong { display: block; color: #fff; font-size: 0.9rem; line-height: 1.2; }
.logo-text small  { color: rgba(255,255,255,.6); font-size: 0.72rem; }

.sidebar-nav { flex: 1; padding: 0.5rem 0; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.nav-section-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 1rem 1rem 0.25rem;
}
.sidebar-nav li a,
.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 1rem;
  color: rgba(255,255,255,.78);
  font-size: 0.875rem;
  border-radius: 0;
  transition: background .15s, color .15s;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.sidebar-nav li a:hover,
.sidebar-logout-btn:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav li a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.sidebar-nav li a i,
.sidebar-logout-btn i { width: 18px; text-align: center; font-size: 0.875rem; }
.sidebar-logout-btn:hover { color: #f87171; }

.sidebar-footer {
  padding: 0.9rem 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 0.8rem;
  color: rgba(255,255,255,.6);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  transition: margin-left .25s ease;
}
.main-content.expanded { margin-left: 0; }
.content-area { padding: 1.5rem; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}
.stat-icon.green  { background: #dcfce7; color: var(--success); }
.stat-icon.blue   { background: #dbeafe; color: var(--primary); }
.stat-icon.orange { background: #fef3c7; color: var(--accent); }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table { font-size: 0.875rem; }
.table th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase;
            letter-spacing: .04em; color: var(--text-muted); }
.table-hover tbody tr:hover { background: #f8faff; }
code { font-size: 0.8rem; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; color: #1e293b; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.15);
}
.form-label { font-weight: 600; font-size: 0.875rem; color: #334155; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress { border-radius: 50px; background: #e2e8f0; }
.progress-bar { border-radius: 50px; }

/* ── Messages container ──────────────────────────────────────────────────── */
.messages-container { max-width: 900px; margin: 0 auto 1rem; }
.alert { border-radius: 8px; font-size: 0.875rem; }

/* ── Member avatar ───────────────────────────────────────────────────────── */
.member-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 2px;
  line-height: 1.2;
}
.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}
.breadcrumb-area {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.breadcrumb-area a { color: var(--primary); }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-pending_guarantor { background: #e0e7ff; color: #3730a3; }
.badge-guarantor_rejected { background: #fee2e2; color: #991b1b; }
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-approved  { background: #dbeafe; color: #1e40af; }
.badge-implemented { background: #dcfce7; color: #15803d; }
.badge-rejected  { background: #fee2e2; color: #991b1b; }
.badge-closed    { background: #f1f5f9; color: #475569; }
.badge-delivered { background: #ede9fe; color: #5b21b6; }
.badge-initiated { background: #f0fdf4; color: #166534; }
.badge-successful{ background: #dcfce7; color: #15803d; }
.badge-failed    { background: #fee2e2; color: #991b1b; }
.badge-partially_refunded { background: #dbeafe; color: #1e40af; }
.badge-refunded  { background: #dcfce7; color: #15803d; }
.badge-voided    { background: #f1f5f9; color: #475569; }
.badge-completed { background: #f1f5f9; color: #475569; }

/* ── Custom buttons ──────────────────────────────────────────────────────── */
.btn-primary-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-primary-custom:hover { background: var(--primary-dk); color: #fff; text-decoration: none; }

.btn-accent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--accent);
  color: #1e293b;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}
.btn-accent:hover { opacity: .9; color: #1e293b; text-decoration: none; }

.btn-sm-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn-sm-action:hover { background: var(--primary-dk); color: #fff; text-decoration: none; }
.btn-sm-action.success { background: var(--success); }
.btn-sm-action.success:hover { background: #138a3a; }
.btn-sm-action.warning { background: #f59e0b; }
.btn-sm-action.warning:hover { background: #d97706; }
.btn-sm-action.danger { background: var(--danger); }

/* ── Form sections ───────────────────────────────────────────────────────── */
.form-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.form-section-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-body { padding: 1.5rem 1.25rem; }

/* ── Savings hero banner ─────────────────────────────────────────────────── */
.savings-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #0ea5e9 100%);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  color: #fff;
  text-align: center;
  box-shadow: 0 4px 16px rgba(26,86,219,.25);
}
.savings-label {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.savings-amount {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; opacity: .4; }
.empty-state h5 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; color: #64748b; }
.empty-state p  { font-size: 0.875rem; margin-bottom: 0; }

/* ── Member card (table rows) ────────────────────────────────────────────── */
.member-card {
  display: flex;
  align-items: center;
  gap: 10px;
}
.member-card .member-avatar { flex-shrink: 0; }

/* ── Card header flex ────────────────────────────────────────────────────── */
.card-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-header .ms-auto { margin-left: auto; }
