/* ============================================================
   QOOPONE Cooperative System - Premium CSS
   ============================================================ */

/* Logo brightness boost for dark backgrounds:
   The QoopOne logo has dark teal text (#005658) that is
   hard to read on dark navy/black backgrounds.
   brightness(2.5) lifts it to a readable mid-light teal. */
img.qoop-logo-dark {
    filter: brightness(3);
}

/* -- Variables -- */
:root {
    --primary: #4F46E5;
    --primary-light: #6366f1;
    --primary-dark: #3730a3;
    --primary-glow: rgba(79, 70, 229, 0.3);
    --accent: #10B981;
    --accent-light: #34d399;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    --sidebar-bg: #0f0f1a;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-width: 265px;
    --sidebar-collapsed-width: 68px;

    --bg-main: #0d0d1a;
    --bg-card: #111827;
    --bg-card-hover: #1a2235;
    --bg-input: #1f2937;
    --bg-table-row: rgba(255, 255, 255, 0.02);
    --bg-table-hover: rgba(79, 70, 229, 0.08);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(79, 70, 229, 0.6);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.5);
    --topbar-height: 64px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* -- Reset & Base -- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body.coop-body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    letter-spacing: -0.01em;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.coop-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow: hidden;
}

.coop-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 70px;
    flex-shrink: 0;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text {
    overflow: hidden;
    white-space: nowrap;
}

.brand-name {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.sidebar-search i {
    color: var(--text-muted);
    font-size: 13px;
}

.sidebar-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    width: 100%;
    font-family: inherit;
}

.sidebar-search input::placeholder {
    color: var(--text-muted);
}

.coop-sidebar.collapsed .sidebar-search,
.coop-sidebar.collapsed .brand-text {
    display: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.2px;
    padding: 12px 20px 4px;
    text-transform: uppercase;
}

.coop-sidebar.collapsed .nav-section-label {
    visibility: hidden;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    white-space: nowrap;
}

.sidebar-nav .nav-link i {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(16, 185, 129, 0.1));
    color: var(--primary-light);
    border: 1px solid rgba(79, 70, 229, 0.3);
}

.sidebar-nav .nav-link.active i {
    color: var(--primary-light);
}

.coop-sidebar.collapsed .sidebar-nav .nav-link span,
.coop-sidebar.collapsed .sidebar-nav .badge-pill {
    display: none;
}

.coop-sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 10px;
    margin: 2px 10px;
}

.coop-sidebar.collapsed .sidebar-nav .submenu-arrow {
    display: none;
}

.coop-sidebar.collapsed .sidebar-nav .submenu {
    display: none !important;
}

/* Sidebar Submenu */
.sidebar-nav .submenu {
    padding-left: 14px;
    margin-bottom: 6px;
    transition: var(--transition);
}

.sidebar-nav .submenu .nav-link {
    font-size: 13px;
    padding: 8px 16px;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.sidebar-nav .submenu .nav-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.sidebar-nav .submenu .nav-link.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-light);
    border: none;
}

.sidebar-nav .submenu-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
    opacity: 0.7;
}

.sidebar-nav .nav-link:not(.collapsed) .submenu-arrow {
    transform: rotate(180deg);
}

.badge-pill {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-logout:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.coop-sidebar.collapsed .user-info,
.coop-sidebar.collapsed .btn-logout {
    display: none;
}

/* ── Main Content ─────────────────────────────────────────────── */
.coop-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.coop-main.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* ── Top Bar ─────────────────────────────────────────────────── */
.coop-topbar {
    height: var(--topbar-height);
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.breadcrumb {
    margin: 0;
    background: none;
    padding: 0;
}

.breadcrumb-item {
    font-size: 13px;
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

.breadcrumb-item+.breadcrumb-item::before {
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.topbar-profile {
    text-decoration: none;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.avatar-sm:hover {
    transform: scale(1.1);
}

/* ── Content Area ─────────────────────────────────────────────── */
.coop-content {
    padding: 28px;
    flex: 1;
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Stats Cards ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), transparent);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevated);
    border-color: rgba(255, 255, 255, 0.12);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card-icon.primary {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-light);
}

.stat-card-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-light);
}

.stat-card-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-card-icon.danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.stat-card-icon.info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.stat-card-icon.purple {
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-trend {
    font-size: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-trend.up {
    color: var(--accent);
}

.stat-trend.down {
    color: var(--danger);
}

/* ── Coop Card ─────────────────────────────────────────────── */
.coop-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.coop-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.coop-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.coop-card-title i {
    color: var(--primary-light);
}

.coop-card-body {
    padding: 24px;
}

.coop-card-body.p-0 {
    padding: 0;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}

/* Custom scrollbar for horizontal table scrolling */
.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #0d6efd);
}

.coop-table {
    width: 100%;
    border-collapse: collapse;
}

.coop-table thead th {
    background: rgba(255, 255, 255, 0.03);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.coop-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.coop-table tbody tr:hover {
    background: var(--bg-table-hover);
}

.coop-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    vertical-align: middle;
}

.coop-table tbody td:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Badges / Status Chips ─────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-light);
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-badge.suspended {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status-badge.approved {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.status-badge.rejected {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.status-badge.settled {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-light);
}

.status-badge.defaulted {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.status-badge.blacklist {
    background: rgba(15, 15, 15, 0.8);
    color: #f87171;
    border: 1px solid var(--danger);
}

.status-badge.dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary-coop {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary-coop:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
    color: white;
}

.btn-secondary-coop {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-secondary-coop:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-success-coop {
    background: linear-gradient(135deg, #059669, var(--accent));
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-success-coop:hover {
    opacity: 0.9;
    color: white;
}

.btn-danger-coop {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-danger-coop:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.btn-outline-coop {
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--primary-light);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-outline-coop:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control,
.form-select {
    width: 100%;
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary) !important;
    padding: 10px 14px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control option,
.form-select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

.input-group-addon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-muted);
}

.text-field-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.field-required::after {
    content: ' *';
    color: var(--danger);
}

/* ── Search Bar ─────────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    flex: 1;
    max-width: 350px;
}

.search-bar i {
    color: var(--text-muted);
}

.search-bar input {
    background: none;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
}

/* ── Filters Bar ─────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filters-bar-selects {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Pagination ─────────────────────────────────────────────── */
.coop-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    gap: 4px;
}

.pagination-links a,
.pagination-links span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.pagination-links a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.pagination-links .active-page {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Detail Card ─────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.detail-item label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: block;
    margin-bottom: 6px;
}

.detail-item span {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Timeline / Activity ─────────────────────────────────────── */
.timeline {
    padding: 0;
    list-style: none;
}

.timeline-item {
    display: flex;
    gap: 16px;
    padding-bottom: 20px;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 32px;
    bottom: 0;
    width: 1px;
    background: var(--border);
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.timeline-content {
    flex: 1;
}

.timeline-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Sidebar Overlay (mobile) ────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ── Alert Toasts ────────────────────────────────────────────── */
.alert-toast {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    max-width: 400px;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
    box-shadow: var(--shadow-elevated);
}

.alert-toast.success {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.9), rgba(16, 185, 129, 0.8));
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: white;
}

.alert-toast.warning {
    background: linear-gradient(135deg, rgba(161, 98, 7, 0.9), rgba(245, 158, 11, 0.8));
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: white;
}

.alert-toast.error {
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.9), rgba(239, 68, 68, 0.8));
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: white;
}

.alert-toast i {
    font-size: 18px;
    flex-shrink: 0;
}

.alert-toast span {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.alert-toast button {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    padding: 0;
    font-size: 16px;
}

.alert-toast button:hover {
    color: white;
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ── Dashboard Charts placeholder ───────────────────────────── */
.chart-placeholder {
    height: 200px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    border: 1px dashed var(--border);
}

/* ── Member Avatar ───────────────────────────────────────────── */
.member-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.member-info .member-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.member-info .member-id {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Progress Bar ────────────────────────────────────────────── */
.progress-coop {
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-coop {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.6s ease;
}

/* ── Modal Overrides ─────────────────────────────────────────── */
.modal-content {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    color: var(--text-primary) !important;
}

.modal-header {
    border-bottom: 1px solid var(--border) !important;
    padding: 20px 24px !important;
}

.modal-title {
    font-weight: 700 !important;
}

.modal-body {
    padding: 24px !important;
}

.modal-footer {
    border-top: 1px solid var(--border) !important;
    padding: 16px 24px !important;
}

.btn-close {
    filter: invert(1) !important;
}

/* ── Validation ──────────────────────────────────────────────── */
.field-validation-error,
.text-danger {
    color: #f87171 !important;
    font-size: 12px;
}

.input-validation-error {
    border-color: var(--danger) !important;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.coop-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.coop-tab {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    text-decoration: none;
    border: none;
    background: none;
}

.coop-tab.active {
    background: var(--primary);
    color: white;
}

.coop-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

/* ── Loan Amortization Table ─────────────────────────────────── */
.amort-paid {
    opacity: 0.5;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (max-width: 1024px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 230px;
    }

    .coop-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .topbar-date {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (max-width: 768px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ─── Sidebar ─────────────────────────────────────────────── */
    .coop-sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        width: var(--sidebar-width) !important; /* keep full width when open */
        box-shadow: 4px 0 40px rgba(0,0,0,0.6);
    }

    .coop-sidebar.mobile-open {
        transform: translateX(0);
    }

    /* ─── Main content ────────────────────────────────────────── */
    .coop-main {
        margin-left: 0 !important;
    }

    /* ─── Topbar ──────────────────────────────────────────────── */
    .coop-topbar {
        padding: 0 14px;
        height: 56px;
    }

    .topbar-date {
        display: none;
    }

    /* Collapse notification dropdown width on mobile */
    .topbar-right .dropdown-menu {
        width: calc(100vw - 32px) !important;
        max-width: 340px;
    }

    /* ─── Content padding ─────────────────────────────────────── */
    .coop-content {
        padding: 14px;
    }

    /* ─── Page header ─────────────────────────────────────────── */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 18px;
    }

    .page-title {
        font-size: 20px;
    }

    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    /* Do NOT stretch single buttons — just wrap nicely */
    .page-actions .btn,
    .page-actions .btn-primary-coop,
    .page-actions .btn-secondary-coop {
        flex: 0 0 auto;
        min-width: 130px;
        justify-content: center;
    }

    /* ─── Stats grid ──────────────────────────────────────────── */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 18px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 22px;
    }

    /* ─── Cards ───────────────────────────────────────────────── */
    .coop-card-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .coop-card-body {
        padding: 14px 16px;
    }

    /* ─── Tables ──────────────────────────────────────────────── */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
    }

    /* Make table cells more touch-friendly */
    .coop-table tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .coop-table thead th {
        padding: 10px 12px;
        font-size: 10px;
    }

    /* ─── Filters bar ─────────────────────────────────────────── */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    /* Search stays full width */
    .filters-bar .search-bar {
        width: 100%;
        max-width: 100%;
        min-width: unset;
    }

    /* Selects side-by-side in a row */
    .filters-bar-selects {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .filters-bar-selects .form-select,
    .filters-bar-selects select {
        flex: 1;
        width: auto !important;
        min-width: 0;
    }

    /* Filter/Clear buttons inline row */
    .filters-bar-actions {
        display: flex;
        gap: 8px;
    }

    .filters-bar-actions .btn-primary-coop,
    .filters-bar-actions .btn-secondary-coop {
        flex: 1;
        justify-content: center;
    }

    /* Fallback: if selects are direct children (no wrapper), keep them shorter */
    .filters-bar > .form-select,
    .filters-bar > select {
        width: 100%;
    }

    .search-bar {
        max-width: 100%;
        min-width: unset;
    }

    /* ─── Pagination ──────────────────────────────────────────── */
    .coop-pagination {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 14px 16px;
        text-align: center;
    }

    /* ─── Detail grid ─────────────────────────────────────────── */
    .detail-grid {
        grid-template-columns: 1fr;
    }

    /* ─── Profile header ──────────────────────────────────────── */
    .profile-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px 16px;
        gap: 16px;
    }

    /* ─── Tabs ────────────────────────────────────────────────── */
    .coop-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .coop-tabs::-webkit-scrollbar {
        display: none;
    }

    .coop-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* ─── Modals ──────────────────────────────────────────────── */
    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px) !important;
    }

    .modal-body {
        padding: 16px !important;
    }

    .modal-header {
        padding: 14px 16px !important;
    }

    .modal-footer {
        padding: 12px 16px !important;
        flex-wrap: wrap;
    }

    /* ─── Alert toasts ────────────────────────────────────────── */
    .alert-toast {
        right: 12px;
        left: 12px;
        max-width: calc(100vw - 24px);
        min-width: unset;
        top: 68px;
    }

    /* ─── Bootstrap grid helpers on mobile ────────────────────── */
    .row {
        --bs-gutter-x: 12px;
    }

    /* ─── Form controls touch-friendly ───────────────────────── */
    .form-control,
    .form-select {
        font-size: 16px !important; /* prevent iOS zoom on focus */
        padding: 10px 12px;
    }

    /* ─── Buttons touch-friendly ──────────────────────────────── */
    .btn,
    .btn-primary-coop,
    .btn-secondary-coop,
    .btn-success-coop,
    .btn-danger-coop {
        min-height: 44px;
    }

    /* ─── Collapse submenus in sidebar - already handled by JS ── */

    /* ─── Topbar right: hide date, tighten gap ────────────────── */
    .topbar-right {
        gap: 10px;
    }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Small phones (max-width: 480px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px 12px;
    }

    .stat-value {
        font-size: 19px;
    }

    .stat-card-icon {
        width: 38px;
        height: 38px;
        font-size: 18px;
        margin-bottom: 10px;
    }

    .page-title {
        font-size: 18px;
    }

    /* Single column stats on very small phones */
    .stats-grid.single-col-xs {
        grid-template-columns: 1fr;
    }

    /* Stack page action buttons fully */
    .page-actions .btn,
    .page-actions .btn-primary-coop,
    .page-actions .btn-secondary-coop {
        width: 100%;
    }

    /* Slim down card padding */
    .coop-card-body {
        padding: 12px;
    }

    .coop-card-header {
        padding: 12px;
    }
}

/* ── Utility classes ─────────────────────────────────────────── */
.text-money {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.currency::before {
    content: '₦';
    font-size: 0.85em;
}

.bg-dark-section {
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 15px;
}

/* ── Bootstrap overrides for dark mode ──────────────────────── */
.table {
    color: var(--text-secondary);
}

.alert {
    border-radius: var(--radius-sm);
}

.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-elevated);
}

.dropdown-item {
    color: var(--text-secondary);
    font-size: 14px;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

/* ── Tab Navigation ──────────────────────────────────────────── */
.coop-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.coop-tab {
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
    transition: var(--transition);
}

.coop-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.coop-tab.active {
    background: rgba(79, 70, 229, 0.18);
    color: var(--primary-light);
    border-color: rgba(79, 70, 229, 0.4);
}

/* ── Amortization / Repayment Schedule ───────────────────────── */
.amort-paid td {
    opacity: 0.55;
    text-decoration-line: none;
}

.amort-paid td:first-child {
    opacity: 0.55;
}

/* ── Progress Bar ────────────────────────────────────────────── */
.progress-coop {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    overflow: hidden;
}

.progress-bar-coop {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--primary-light));
    border-radius: 20px;
    transition: width 0.6s ease;
    min-width: 4px;
}

/* ── Form Helpers ────────────────────────────────────────────── */
.text-field-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.field-required::after {
    content: ' *';
    color: var(--danger);
}

.field-validation-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* ── Detail Grid ─────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.detail-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
}

.detail-item span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── KYC / Profile Section ───────────────────────────────────── */
.profile-header {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(16, 185, 129, 0.08));
    border-radius: var(--radius-lg);
    padding: 28px;
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 28px;
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.member-avatar-lg {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 8px 24px var(--primary-glow);
}

/* ── Filters Bar ─────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px;
}

.search-bar i {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

/* ── Member Avatar (table) ────────────────────────────────────── */
.member-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.member-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.member-id {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Modal Overrides ─────────────────────────────────────────── */
.modal-content {
    background: #161625;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    gap: 10px;
}

.btn-close {
    filter: invert(1);
    opacity: 0.5;
}

.btn-close:hover {
    opacity: 0.8;
}

/* ── Pagination ──────────────────────────────────────────────── */
.coop-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.pagination-links {
    display: flex;
    gap: 4px;
}

.pagination-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.pagination-links a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.pagination-links a.active-page {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px var(--primary-glow);
}

/* ── Mobile Member Cards ─────────────────────────────────────── */
.member-cards-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.member-mobile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.member-mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.member-mobile-card-body {
    padding: 4px 0;
}

.member-mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    gap: 12px;
}

.member-mobile-row:last-child {
    border-bottom: none;
}

.member-mobile-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    flex-shrink: 0;
}

/* ── Topbar mobile fix ───────────────────────────────────────── */
@media (max-width: 768px) {
    .coop-topbar {
        background: #0f172a;
        backdrop-filter: none;
        border-bottom-color: rgba(255,255,255,0.1);
    }

    /* Larger tap target for sidebar toggle */
    .sidebar-toggle {
        font-size: 24px;
        padding: 8px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    /* Give the topbar brand name on mobile */
    .topbar-mobile-title {
        font-size: 14px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }

    /* Filters-bar wrapper rows */
    .filters-bar-selects {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .filters-bar-actions {
        display: flex;
        gap: 8px;
    }
}

/* ── Notifications ───────────────────────────────────────────── */
.notification-list {
    display: flex;
    flex-direction: column;
}

.notification-item {
    display: block;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    transition: var(--transition);
    color: var(--text-secondary);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--bg-table-hover);
    color: var(--text-primary);
}

.notification-item.unread {
    background: rgba(79, 70, 229, 0.03);
}

.notification-item.unread:hover {
    background: rgba(79, 70, 229, 0.07);
}

.notification-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.notification-title-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.notification-item.unread .notification-title {
    font-weight: 700;
}

.notification-dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary-light);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px var(--primary-light);
}

.notification-time {
    font-size: 12px;
    color: var(--text-muted);
}

.notification-message {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.notification-item:hover .notification-message {
    color: var(--text-primary);
}

/* ══════════════════════════════════════════════════════════════
   MOBILE DETAIL PAGE — Avatar + Action Header
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Page-header with large avatar (Details pages) */
    .page-header > .d-flex.align-items-center.gap-4,
    .page-header > div:first-child.d-flex {
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-header > .d-flex.align-items-center.gap-4 > div[style*="72px"],
    .page-header > .d-flex.align-items-center.gap-4 > div[style*="80px"] {
        flex-shrink: 0;
    }

    /* Allow page-actions to wrap below on small screens */
    .page-header {
        gap: 12px;
    }

    .page-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Buttons in page-actions: wrap but stay auto-width */
    .page-actions .btn-primary-coop,
    .page-actions .btn-secondary-coop,
    .page-actions .btn-success-coop,
    .page-actions .btn-danger-coop,
    .page-actions .btn {
        flex: 0 0 auto;
    }

    /* Card-header wrapping for complex headers */
    .coop-card-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Detail grid: always single-column on phone */
    .detail-grid {
        grid-template-columns: 1fr !important;
    }

    /* Member-mobile-card padding refinements */
    .member-mobile-card {
        margin-bottom: 0;
    }

    .member-mobile-card-header {
        gap: 8px;
    }

    /* Loan card inside coop-card */
    .coop-card-body .member-mobile-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
    }
    .coop-card-body .member-mobile-card:first-child {
        border-top: none;
    }

    /* Search bar inside coop-card-header */
    .coop-card-header form.d-flex {
        flex-wrap: nowrap;
    }
    .coop-card-header form.d-flex .search-bar {
        flex: 1;
        min-width: 0;
    }

    /* Tabs: allow horizontal scroll without wrapping */
    .coop-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }
    .coop-tabs::-webkit-scrollbar {
        display: none;
    }
    .coop-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Impersonation banner: wrap text */
    .coop-main > div[style*="linear-gradient"] span {
        font-size: 12px;
        line-height: 1.4;
    }

    /* Bootstrap col-md overrides: stack columns on mobile */
    .col-md-8,
    .col-md-4,
    .col-md-3,
    .col-md-6 {
        /* Bootstrap handles this, but ensure no overflow */
        max-width: 100%;
    }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE FORM GRID — col-md-6 / col-md-3 stacking
══════════════════════════════════════════════════════════════ */
@media (max-width: 576px) {
    /* Inside Bootstrap row g-3/g-4 forms — ensure full width on phone */
    .row.g-3 > .col-md-6,
    .row.g-3 > .col-md-4,
    .row.g-3 > .col-md-3,
    .row.g-4 > .col-md-6,
    .row.g-4 > .col-md-4,
    .row.g-4 > .col-md-3 {
        /* Bootstrap's col-md already handles this at md breakpoint,
           but this catches any residual fixed widths */
        width: 100%;
    }

    /* Profile/member header on small phones */
    .profile-header {
        padding: 16px;
        gap: 12px;
    }
    .member-avatar-lg {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
}

/* ══════════════════════════════════════════════════════════════
   SAFE AREA & BOTTOM SPACING (iOS / Android notch support)
══════════════════════════════════════════════════════════════ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .coop-sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
    @media (max-width: 768px) {
        .coop-content {
            padding-bottom: calc(14px + env(safe-area-inset-bottom));
        }
    }
}

/* ══════════════════════════════════════════════════════════════
   TOPBAR MOBILE BRAND TITLE (shown only on mobile)
══════════════════════════════════════════════════════════════ */
.topbar-mobile-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    flex: 1;
    min-width: 0;
}

/* Ensure topbar-left doesn't overflow on mobile */
@media (max-width: 768px) {
    .topbar-left {
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }
}

/* ══════════════════════════════════════════════════════════════
   IMPROVED EMPTY STATE ON MOBILE
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .empty-state {
        padding: 40px 16px;
    }
    .empty-state i {
        font-size: 36px;
    }
}

/* ══════════════════════════════════════════════════════════════
   IMPROVED MODAL ON SMALL PHONES
══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .modal-dialog {
        margin: 6px;
        max-width: calc(100vw - 12px) !important;
    }
    .modal-body {
        padding: 12px !important;
    }
    .modal-header,
    .modal-footer {
        padding: 12px !important;
    }
}

/* ══════════════════════════════════════════════════════════════
   LOAN / SAVINGS DETAIL PAGE — stacked action buttons
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* d-flex gap-2 flex-wrap fix for action button groups */
    .d-flex.gap-2.flex-wrap {
        flex-wrap: wrap;
    }

    /* Bootstrap .row.g-4 used in Details pages  */
    .row.g-4 {
        --bs-gutter-x: 14px;
        --bs-gutter-y: 14px;
    }
    .row.g-3 {
        --bs-gutter-x: 10px;
        --bs-gutter-y: 10px;
    }
}