/* =============================================================================
   Church Management System - Stylesheet (Sidebar + Responsive)
   ============================================================================= */

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

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #dbeafe;
    --secondary:     #64748b;
    --success:       #16a34a;
    --danger:        #dc2626;
    --warning:       #f59e0b;
    --dark-bg:       #0f172a;
    --dark-surface:  #1e293b;
    --light:         #f8fafc;
    --border:        #e2e8f0;
    --text:          #334155;
    --text-muted:    #94a3b8;
    --radius:        8px;
    --shadow:        0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:     0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --sidebar-w:     260px;
    --topbar-h:      56px;
    --transition:    0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
                 Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: #f1f5f9;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

h2, h3, h4 { color: var(--dark-surface); }

/* =========================================================================
   SIDEBAR
   ========================================================================= */

.sidebar-toggle { display: none; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 90;
    transition: opacity var(--transition);
}

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--dark-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    transition: transform var(--transition);
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand a {
    font-size: 20px;
    font-weight: 700;
    color: #fff !important;
    letter-spacing: -0.3px;
}

.sidebar-brand-logo {
    border-radius: 6px;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.sidebar-section {
    padding: 20px 24px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #475569;
    font-weight: 700;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    margin: 0 8px;
    border-radius: var(--radius);
    color: #94a3b8;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.15s;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}

.sidebar-link.active {
    background: rgba(37,99,235,0.25);
    color: #fff;
    font-weight: 600;
}

.sidebar-icon { flex-shrink: 0; opacity: 0.55; }
.sidebar-link.active .sidebar-icon { opacity: 1; }

.sidebar-user {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-user-info { line-height: 1.4; }
.sidebar-user-info strong { font-size: 13px; color: #e2e8f0; display: block; }
.sidebar-user-info small  { font-size: 11px; color: #64748b; text-transform: capitalize; }

.sidebar-logout {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #94a3b8;
    padding: 5px 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
    transition: all 0.15s;
    text-decoration: none !important;
}
.sidebar-logout:hover {
    background: rgba(220,38,38,0.2);
    border-color: var(--danger);
    color: #fca5a5;
}

/* =========================================================================
   MAIN CONTENT AREA
   ========================================================================= */

.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.hamburger {
    display: none;
    cursor: pointer;
    color: var(--text);
    padding: 6px;
    line-height: 0;
    user-select: none;
    border-radius: var(--radius);
    transition: background 0.15s;
    background: none;
    border: none;
}
.hamburger:hover { background: var(--light); }

.topbar-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--dark-surface);
}

.main-content {
    flex: 1;
    padding: 24px;
}

.footer {
    text-align: center;
    padding: 14px 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    background: #fff;
}

/* =========================================================================
   LOGIN PAGE
   ========================================================================= */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 40%, #1e3a5f 70%, #1d4ed8 100%);
    padding: 20px;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-card-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-bottom: 14px;
}

.login-card-logo img {
    display: block;
    border-radius: 16px;
}

.login-card-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--dark-surface);
    margin: 0 0 4px;
    letter-spacing: -0.2px;
}

.login-card-subtitle {
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 24px;
}

.login-brand h1 {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.login-brand p {
    font-size: 14px;
    color: rgba(255,255,255,0.55);
    font-weight: 400;
}

.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.05);
}

.login-card .alert {
    border-radius: 8px;
    margin-bottom: 20px;
}

.login-card .alert svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.login-card form {
    margin-top: 4px;
}

.login-card .form-group {
    margin-bottom: 18px;
}

.login-card .form-group label {
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--dark-surface);
}

.login-card .form-control {
    padding: 10px 14px;
    font-size: 14px;
    border-color: #d1d5db;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.login-card .form-control::placeholder {
    color: #cbd5e1;
}

.login-card .btn-lg {
    padding: 12px 24px;
    font-size: 15px;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.login-card .btn-block {
    margin-top: 6px;
}

/* Input with icon */
.input-icon {
    position: relative;
}

.input-icon .input-icon-svg {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.input-icon .form-control {
    padding-left: 38px;
}

/* Password toggle button */
.input-password .form-control {
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    z-index: 1;
}

.password-toggle:hover {
    color: #64748b;
    background: #f1f5f9;
}

.eye-icon { display: none; }
.password-toggle .eye-off { display: block; }
.password-toggle.visible .eye-off { display: none; }
.password-toggle.visible .eye-on { display: block; }

/* Remember me checkbox */
.form-row-inline {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-label .checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: rgba(255,255,255,0.4);
}

.login-footer code {
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.1);
}

/* =========================================================================
   LOGIN SUCCESS MODAL
   ========================================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay.modal-visible {
    animation: modalFadeIn 0.3s ease;
}

.modal-dialog {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    animation: modalScaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-success h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark-surface);
    margin: 20px 0 8px;
}

.modal-welcome {
    font-size: 14px;
    color: var(--text);
    margin: 0 0 6px;
}

.modal-redirect {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 20px;
}

.modal-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.7s linear infinite;
}

.success-checkmark svg {
    display: block;
    margin: 0 auto;
}

.check-circle {
    stroke-dasharray: 190;
    stroke-dashoffset: 190;
    animation: drawCircle 0.6s 0.1s ease forwards;
}

.check-path {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: drawCheck 0.4s 0.4s ease forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalScaleIn {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes drawCircle {
    to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

.modal-confirm {
    max-width: 360px;
    padding: 36px 32px 28px;
}

.modal-confirm h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark-surface);
    margin: 14px 0 6px;
}

.modal-confirm p {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 0 0 24px;
}

.confirm-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fee2e2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-actions .btn {
    min-width: 100px;
    padding: 9px 20px;
    font-size: 14px;
}

/* =========================================================================
   PAGE HEADER
   ========================================================================= */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header-left h1 {
    font-size: 20px;
    margin: 0;
    color: var(--dark-surface);
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =========================================================================
   CARDS
   ========================================================================= */

.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 15px; margin: 0; font-weight: 600; }
.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* =========================================================================
   STATS
   ========================================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow 0.2s, transform 0.15s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-accent-blue   .stat-icon-box { background: #dbeafe; color: #2563eb; }
.stat-accent-green  .stat-icon-box { background: #dcfce7; color: #16a34a; }
.stat-accent-purple .stat-icon-box { background: #f3e8ff; color: #9333ea; }
.stat-accent-orange .stat-icon-box { background: #fff7ed; color: #ea580c; }
.stat-accent-red    .stat-icon-box { background: #fee2e2; color: #dc2626; }
.stat-accent-teal   .stat-icon-box { background: #ccfbf1; color: #0d9488; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark-surface);
    line-height: 1.2;
}

.stat-title {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* =========================================================================
   DASHBOARD WELCOME
   ========================================================================= */

.dash-welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 14px;
}

.dash-welcome-text h1 {
    font-size: 22px;
    margin: 0;
    color: var(--dark-surface);
}

.dash-welcome-text p {
    margin: 4px 0 0;
    font-size: 13.5px;
    color: var(--text-muted);
}

/* =========================================================================
   DASHBOARD & DETAIL GRIDS
   ========================================================================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* Modern card variant */
.card-modern {
    border-radius: 12px;
}

.card-modern .card-header {
    padding: 18px 22px;
}

.card-modern .card-body {
    padding: 0;
}

.card-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none !important;
}

.card-link:hover {
    color: var(--primary-dark);
}

/* Member row */
.member-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    text-decoration: none !important;
    color: inherit;
    transition: background 0.12s;
    border-bottom: 1px solid #f1f5f9;
}

.member-row:last-child { border-bottom: none; }

.member-row:hover { background: #f8fafc; }

.member-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.member-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.member-info strong {
    font-size: 13.5px;
    color: var(--dark-surface);
}

.member-info span {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.member-meta {
    flex-shrink: 0;
}

/* Event row */
.event-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 22px;
    border-bottom: 1px solid #f1f5f9;
}

.event-row:last-child { border-bottom: none; }

.event-date-badge {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-align: center;
}

.event-day {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark-surface);
    line-height: 1;
}

.event-month {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.event-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.event-info strong {
    font-size: 13.5px;
    color: var(--dark-surface);
}

.event-info > span {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.event-type-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: capitalize;
}

.accent-blue    { background: #dbeafe; color: #1d4ed8; }
.accent-green   { background: #dcfce7; color: #15803d; }
.accent-purple  { background: #f3e8ff; color: #7c3aed; }
.accent-pink    { background: #fce7f3; color: #be185d; }
.accent-gray    { background: #f1f5f9; color: #475569; }
.accent-teal    { background: #ccfbf1; color: #0f766e; }
.accent-orange  { background: #fff7ed; color: #c2410c; }
.accent-indigo  { background: #e0e7ff; color: #4338ca; }
.accent-amber   { background: #fef3c7; color: #b45309; }

/* Offering row */
.offering-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    border-bottom: 1px solid #f1f5f9;
}

.offering-row:last-child { border-bottom: none; }

.offering-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #dcfce7;
    color: #16a34a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.offering-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.offering-info strong {
    font-size: 13.5px;
    color: var(--dark-surface);
}

.offering-info span {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.offering-amount {
    font-size: 14px;
    font-weight: 700;
    color: #15803d;
    flex-shrink: 0;
}

/* Action grid */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    text-decoration: none !important;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

.action-card:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: var(--primary);
}

.action-card svg {
    opacity: 0.6;
}

.action-card:hover svg {
    opacity: 1;
}

/* =========================================================================
   BUTTONS
   ========================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.15s;
    line-height: 1.4;
    white-space: nowrap;
    font-family: inherit;
}

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

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

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

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }

/* =========================================================================
   FORMS
   ========================================================================= */

.form-group { margin-bottom: 16px; flex: 1; min-width: 0; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 13px; color: var(--dark-surface); }
.form-group .help-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
select.form-control { appearance: auto; cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.form-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.has-error .form-control { border-color: var(--danger); }
.error-msg { color: var(--danger); font-size: 12px; margin-top: 3px; }
.required  { color: var(--danger); }

.form-actions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    background: #fafbfc;
}
legend {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark-surface);
    padding: 0 10px;
    background: #fafbfc;
}

/* =========================================================================
   TABLES
   ========================================================================= */

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.table th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    background: #f8fafc;
    white-space: nowrap;
}
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.table-sm th, .table-sm td { padding: 7px 12px; font-size: 12.5px; }

.actions { white-space: nowrap; display: flex; gap: 4px; }

.detail-table { width: 100%; }
.detail-table th, .detail-table td {
    padding: 7px 0;
    font-size: 13px;
    vertical-align: top;
}
.detail-table th { width: 140px; color: var(--text-muted); text-align: left; font-weight: 500; white-space: nowrap; }

/* =========================================================================
   ALERTS & BADGES
   ========================================================================= */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    background: var(--border);
    color: var(--text);
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-info     { background: #dbeafe; color: #1e40af; }

/* =========================================================================
   PAGINATION
   ========================================================================= */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 0 4px;
    font-size: 13px;
    color: var(--text-muted);
}
.pagination .btn { min-width: 80px; }

/* =========================================================================
   EMPTY STATE
   ========================================================================= */

/* =========================================================================
   MISC
   ========================================================================= */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state h3 { margin-bottom: 8px; color: var(--text-muted); }

.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* =========================================================================
   FAMILY PROFILING FORM
   ========================================================================= */

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-section {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.profile-section-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 22px;
}

.profile-section-number {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 14px;
    font-weight: 700;
}

.profile-section-heading h2 {
    margin: 0;
    color: var(--dark-surface);
    font-size: 17px;
}

.profile-section-heading p {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
}

.profile-directory-link {
    margin-left: auto;
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.profile-grid {
    display: grid;
    gap: 14px;
}

.profile-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.profile-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.profile-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.profile-grid-span-2 { grid-column: span 2; }

.profile-family-name {
    max-width: 560px;
    margin-top: 14px;
    margin-bottom: 0;
}

.optional-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}

.profile-person-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.profile-person-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafbfc;
}

.profile-person-title {
    color: var(--dark-surface);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
}

.profile-subsection {
    border-top: 1px solid var(--border);
    margin-top: 22px;
    padding-top: 22px;
}

.profile-subsection h3 {
    margin: 0 0 14px;
    font-size: 14px;
}

.children-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.children-heading h3 { margin-bottom: 2px; }
.children-heading p { margin: 0; color: var(--text-muted); font-size: 12px; }

.child-entry {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 14px;
    background: #fafbfc;
}

.child-entry:last-child { margin-bottom: 0; }

.child-entry-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    color: var(--dark-surface);
    font-size: 13px;
}

.remove-child {
    border: 0;
    background: transparent;
    color: var(--danger);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 3px 6px;
}

.remove-child:hover { text-decoration: underline; }

.child-faith-fields { margin-top: 2px; }

.ministry-picker {
    margin-top: 4px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.ministry-picker-title {
    color: var(--dark-surface);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.ministry-picker-title span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}

.ministry-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.ministry-column {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.ministry-column > strong {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 2px;
}

.ministry-column .checkbox-label {
    align-items: flex-start;
    font-size: 12px;
    line-height: 1.35;
}

.profile-form-actions { padding-top: 2px; }

.profile-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 24px;
    margin-bottom: 20px;
    background: linear-gradient(120deg, #eff6ff, #fff);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
}

.profile-summary-card > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-summary-card strong { color: var(--dark-surface); font-size: 15px; }
.profile-summary-card span { color: var(--text-muted); font-size: 12px; }
.profile-summary-label { color: var(--primary) !important; font-size: 11px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.profile-summary-directory { margin-left: auto; }
.profile-summary-directory span:first-child { color: var(--primary); font-size: 11px; text-transform: uppercase; font-weight: 700; }

/* =========================================================================
   TABS & DIRECTORY
   ========================================================================= */

.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--border);
    padding: 0 22px;
    gap: 0;
}

.tab-item {
    padding: 14px 20px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none !important;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tab-item:hover { color: var(--text); }

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.dir-add-form {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.dir-add-form .form-row { align-items: flex-end; }

.directory-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.directory-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--light);
    font-size: 13px;
    transition: background 0.1s;
}

.directory-item:hover { background: #eef2ff; }

.directory-item svg { flex-shrink: 0; color: var(--text-muted); }

.directory-item-info {
    display: flex;
    flex-direction: column;
}

.directory-item strong { color: var(--dark-surface); font-weight: 600; }
.directory-item small { color: var(--text-muted); font-size: 11px; }

.directory-delete {
    border: 0;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: all 0.1s;
}

.directory-delete:hover {
    background: #fee2e2;
    color: var(--danger);
}

.profile-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-tag {
    display: inline-flex;
    padding: 5px 10px;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 500;
}

.profile-tag.service { background: #dcfce7; color: #166534; }
.profile-tag.worship { background: #fef3c7; color: #92400e; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar-toggle:checked ~ .sidebar {
        transform: translateX(0);
    }

    .sidebar-toggle:checked ~ .sidebar-overlay {
        display: block;
        opacity: 1;
    }

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

    .hamburger { display: flex; }

    .dashboard-grid { grid-template-columns: 1fr; }
    .detail-grid    { grid-template-columns: 1fr; }

    .form-row { flex-direction: column; gap: 0; }
    .form-inline { flex-direction: column; align-items: stretch; }

    .dash-welcome { flex-direction: column; align-items: flex-start; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .action-grid { grid-template-columns: repeat(2, 1fr); }

    .profile-person-grid { grid-template-columns: 1fr; }
    .profile-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-summary-card { align-items: flex-start; flex-direction: column; }
    .profile-summary-directory { margin-left: 0 !important; }
    .profile-directory-link { margin-left: 0; }

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

    .main-content { padding: 16px; }
    .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px 16px; gap: 12px; }
    .stat-icon-box { width: 40px; height: 40px; }
    .stat-number { font-size: 18px; }
    .card-body { padding: 14px; }
    fieldset { padding: 16px; }
    .action-grid { grid-template-columns: 1fr 1fr; }
    .member-row, .event-row, .offering-row { padding: 12px 16px; }
    .profile-section { padding: 16px; }
    .profile-grid-2, .profile-grid-3, .profile-grid-4 { grid-template-columns: 1fr; }
    .profile-grid-span-2 { grid-column: auto; }
    .ministry-columns { grid-template-columns: 1fr; }
}
