/* ============================================================
   COOPERATIVE MANAGEMENT SYSTEM — Design System
   A modern, polished interface with a refined colour palette,
   smooth interactions, and careful typography.
   ============================================================ */

:root {
  /* Brand palette — deep teal-navy with warm gold accent */
  --c-primary:        #0d4f5c;
  --c-primary-light:  #12707f;
  --c-primary-dark:   #08323b;
  --c-accent:         #f2a900;
  --c-accent-dark:    #d99500;

  /* Semantic */
  --c-success:        #1a9e6f;
  --c-success-bg:     #e6f7f0;
  --c-danger:         #d64545;
  --c-danger-bg:      #fcebeb;
  --c-warning:        #e0921a;
  --c-warning-bg:     #fdf4e3;
  --c-info:           #2b80b9;
  --c-info-bg:        #e7f2fa;

  /* Neutrals */
  --c-bg:             #f4f6f9;
  --c-surface:        #ffffff;
  --c-border:         #e4e9f0;
  --c-text:           #1f2d3d;
  --c-text-muted:     #6b7c93;
  --c-text-light:     #9aa7b8;

  /* Sidebar */
  --sidebar-w:        264px;
  --sidebar-bg:       #0a3a44;
  --sidebar-hover:    rgba(255,255,255,0.08);

  /* Effects */
  --radius:           14px;
  --radius-sm:        9px;
  --shadow-sm:        0 1px 3px rgba(16,42,67,0.06), 0 1px 2px rgba(16,42,67,0.04);
  --shadow:           0 4px 16px rgba(16,42,67,0.08);
  --shadow-lg:        0 12px 32px rgba(16,42,67,0.14);
  --transition:       all .2s cubic-bezier(.4,0,.2,1);
}

/* ─── Base ─────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: 'Plus Jakarta Sans', 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--c-primary-light); }

h1,h2,h3,h4,h5,h6 { font-weight: 700; color: var(--c-text); letter-spacing: -0.01em; }

/* ─── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #072d35 100%);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;           /* container stays put; only nav scrolls */
  z-index: 1000;
  transition: transform .28s ease;
  box-shadow: 4px 0 24px rgba(0,0,0,0.06);
}

.sidebar-brand {
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;             /* never compress the brand header */
}
.sidebar-brand .badge-label {
  display: inline-block;
  color: var(--c-accent);
  font-size: .64rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 5px;
}
.sidebar-brand h5 {
  color: #fff;
  font-size: 1.05rem;
  margin: 0;
  font-weight: 700;
  line-height: 1.25;
}

.sidebar-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 0 20px; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.nav-section {
  padding: 16px 24px 7px;
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: rgba(255,255,255,0.72);
  font-size: .875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--c-accent);
}
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 11px;
}
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-info .name { color: #fff; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { color: rgba(255,255,255,0.42); font-size: .7rem; }

/* ─── Main layout ──────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 14px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
  backdrop-filter: blur(8px);
}
.topbar .page-title { font-size: 1.1rem; font-weight: 700; margin: 0; color: var(--c-primary); }
.topbar .breadcrumb-sub { font-size: .76rem; color: var(--c-text-muted); margin-top: 1px; }

.content { padding: 30px; flex: 1; }

.app-footer {
  text-align: center;
  padding: 18px;
  font-size: .76rem;
  color: var(--c-text-light);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
}

/* ─── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-pad { padding: 22px; }
.card-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-head h6 { margin: 0; font-size: .95rem; font-weight: 700; }
.card-body { padding: 22px; }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card .stat-top { display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 50px; height: 50px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-label { font-size: .76rem; color: var(--c-text-muted); font-weight: 600; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 2px; }
.stat-meta { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--c-border); font-size: .76rem; color: var(--c-text-muted); display: flex; justify-content: space-between; }

/* Gradient hero card */
.hero-card {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
  border-radius: var(--radius);
  padding: 26px 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-card::after {
  content: '';
  position: absolute;
  top: -40%; right: -10%;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(242,169,0,0.18), transparent 70%);
  border-radius: 50%;
}
.hero-card * { position: relative; z-index: 1; }

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.2;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 13px; font-size: .8rem; }
.btn-lg { padding: 13px 26px; font-size: .95rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--c-primary); color: #fff; box-shadow: 0 2px 8px rgba(13,79,92,0.25); }
.btn-primary:hover { background: var(--c-primary-light); color: #fff; box-shadow: 0 4px 14px rgba(13,79,92,0.32); }

.btn-accent { background: var(--c-accent); color: #fff; box-shadow: 0 2px 8px rgba(242,169,0,0.3); }
.btn-accent:hover { background: var(--c-accent-dark); color: #fff; }

.btn-success { background: var(--c-success); color: #fff; }
.btn-success:hover { background: #15875e; color: #fff; }

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

.btn-light { background: #fff; color: var(--c-text); border-color: var(--c-border); }
.btn-light:hover { background: #f8fafc; }

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

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

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

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 30px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.badge-success { background: var(--c-success-bg); color: var(--c-success); }
.badge-danger  { background: var(--c-danger-bg); color: var(--c-danger); }
.badge-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.badge-info    { background: var(--c-info-bg); color: var(--c-info); }
.badge-primary { background: #e3f0f2; color: var(--c-primary); }
.badge-secondary { background: #eef1f5; color: var(--c-text-muted); }

/* ─── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data thead th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
table.data tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--c-border);
  font-size: .86rem;
  vertical-align: middle;
}
table.data tbody tr { transition: var(--transition); }
table.data tbody tr:hover { background: #f9fbfd; }
table.data tbody tr:last-child td { border-bottom: none; }

.code-ref {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: .78rem;
  color: var(--c-primary);
  background: #eef5f6;
  padding: 2px 7px;
  border-radius: 5px;
}

/* ─── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 17px; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--c-text);
}
.form-label .req { color: var(--c-danger); }

.form-control, .form-select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: inherit;
  color: var(--c-text);
  background: #fff;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--c-primary-light);
  box-shadow: 0 0 0 3px rgba(18,112,127,0.12);
}
.form-control::placeholder { color: var(--c-text-light); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: .76rem; color: var(--c-text-muted); margin-top: 4px; }
.form-error { font-size: .76rem; color: var(--c-danger); margin-top: 4px; }

.input-group { display: flex; align-items: stretch; }
.input-group .input-prefix {
  display: flex; align-items: center;
  padding: 0 13px;
  background: #f4f7fa;
  border: 1px solid var(--c-border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-weight: 700;
  color: var(--c-text-muted);
}
.input-group .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Grid helpers */
.row { display: flex; flex-wrap: wrap; gap: 18px; margin: 0; }
.col { flex: 1; min-width: 0; }
.col-2 { flex: 0 0 calc(16.666% - 15px); }
.col-3 { flex: 0 0 calc(25% - 14px); }
.col-4 { flex: 0 0 calc(33.333% - 12px); }
.col-5 { flex: 0 0 calc(41.666% - 11px); }
.col-6 { flex: 0 0 calc(50% - 9px); }
.col-7 { flex: 0 0 calc(58.333% - 8px); }
.col-8 { flex: 0 0 calc(66.666% - 6px); }
.col-9 { flex: 0 0 calc(75% - 5px); }
.col-12 { flex: 0 0 100%; }

/* ─── Alerts / Flash ───────────────────────────────────────── */
.flash-stack { position: fixed; top: 76px; right: 22px; z-index: 9999; max-width: 360px; }
.alert {
  padding: 13px 17px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .86rem;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.alert-success { background: var(--c-success-bg); color: #146249; border-left: 4px solid var(--c-success); }
.alert-danger  { background: var(--c-danger-bg); color: #9c2f2f; border-left: 4px solid var(--c-danger); }
.alert-warning { background: var(--c-warning-bg); color: #92610f; border-left: 4px solid var(--c-warning); }
.alert-info    { background: var(--c-info-bg); color: #1d5a83; border-left: 4px solid var(--c-info); }

.alert-inline { box-shadow: none; animation: none; }

/* ─── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--c-border);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 18px;
  font-size: .87rem;
  font-weight: 600;
  color: var(--c-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: var(--transition);
}
.tab:hover { color: var(--c-primary); }
.tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}
.page-header h1 { font-size: 1.4rem; margin: 0; }
.page-header .subtitle { font-size: .86rem; color: var(--c-text-muted); margin-top: 2px; }

/* ─── Avatar ───────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-text {
  border-radius: 50%;
  background: #e3f0f2;
  color: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Progress bar ─────────────────────────────────────────── */
.progress {
  height: 7px;
  background: #e9eef4;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--c-primary);
  transition: width .5s ease;
}

/* ─── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8,42,51,0.5);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; animation: fadeIn .2s; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h5 { margin: 0; font-size: 1rem; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--c-border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--c-text-light); line-height: 1; }

/* ─── Utilities ────────────────────────────────────────────── */
.text-muted { color: var(--c-text-muted); }
.text-primary { color: var(--c-primary); }
.text-success { color: var(--c-success); }
.text-danger { color: var(--c-danger); }
.text-warning { color: var(--c-warning); }
.text-center { text-align: center; }
.text-end { text-align: right; }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: .8rem; }
.fs-lg { font-size: 1.1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-grow { flex: 1; }
.d-grid { display: grid; }
.w-100 { width: 100%; }
.hidden { display: none; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--c-text-light); }
.empty-state i { font-size: 2.6rem; opacity: .35; display: block; margin-bottom: 12px; }

.divider { height: 1px; background: var(--c-border); margin: 18px 0; border: none; }

/* Filter pills */
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.pill {
  padding: 7px 15px;
  border-radius: 30px;
  font-size: .82rem;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill:hover { border-color: var(--c-primary-light); color: var(--c-primary); }
.pill.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.pill .count { background: rgba(255,255,255,0.25); padding: 1px 8px; border-radius: 20px; font-size: .72rem; }
.pill:not(.active) .count { background: #eef1f5; color: var(--c-text-muted); }

/* Mobile */
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--c-primary); }

@media (max-width: 992px) {
  .col-3, .col-4 { flex: 0 0 calc(50% - 9px); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .content { padding: 18px; }
  .menu-toggle { display: block; }
  .col, .col-2,.col-3,.col-4,.col-5,.col-6,.col-7,.col-8,.col-9 { flex: 0 0 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}
