:root {
    --bg: #eef1f4;
    --panel: #ffffff;
    --ink: #1f2937;
    --muted: #6b7280;
    --brand: #1370c4;          /* ocean blue */
    --brand-dark: #0f579b;
    --accent: #16a34a;          /* green (money in) */
    --danger: #dc2626;          /* red (money due) */
    --line: #e5e7eb;
    --sidebar: #0b2e5c;         /* deep navy (ocean) */
    --sidebar-ink: #bcd0ea;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-ink);
    flex-direction: column; padding: 8px 10px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 1.05rem; padding: 4px 10px 10px; }
.sidebar .brand i { color: #7cc0ef; font-size: 1.4rem; }
.brand-logo { height: 44px; width: 44px; object-fit: cover; border-radius: 50%; background: #fff; padding: 2px; flex-shrink: 0; }
.brand--logo { justify-content: center; padding: 4px 10px 8px; }
.brand-logo-lg { width: 52px; height: 52px; object-fit: cover; border-radius: 50%; background: #fff; padding: 3px; }
.nav-section { text-transform: uppercase; font-size: .66rem; letter-spacing: .08em; color: #6f86ad; margin: 8px 12px 3px; }
.nav-sec-head { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 8px); background: rgba(255,255,255,.04); border: 0; border-radius: 8px;
    text-transform: uppercase; font-size: .8rem; font-weight: 600; letter-spacing: .06em; color: #9fb6d8; padding: 9px 12px; margin: 8px 4px 4px; cursor: pointer; }
.nav-sec-head:hover { color: #fff; background: rgba(255,255,255,.09); }
.nav-sec-head i { font-size: .85rem; transition: transform .15s ease; }
.nav-sec.collapsed .nav-sec-head i { transform: rotate(-90deg); }
.nav-sec.collapsed .nav-sec-items { display: none; }
.sidebar nav a, .mobile-nav nav a { display: flex; align-items: center; gap: 11px; padding: 7px 12px; border-radius: 8px;
    color: var(--sidebar-ink); text-decoration: none; font-size: .9rem; margin-bottom: 1px; }
.sidebar nav a:hover, .mobile-nav nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active, .mobile-nav nav a.active { background: var(--brand); color: #fff; }
.sidebar nav a i { font-size: 1.05rem; width: 18px; text-align: center; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; background: var(--brand); color: #fff;
    padding: 12px 22px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 650; color: #fff; }
.topbar a, .topbar .text-secondary { color: rgba(255,255,255,.85) !important; }
.topbar .btn-outline-secondary, .topbar .btn-outline-danger { color: #fff; border-color: rgba(255,255,255,.5); }
.topbar .btn-outline-danger:hover { background: rgba(255,255,255,.15); }
.app-content { padding: 22px; }

/* ---------- Panels / buttons ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.text-money { color: var(--accent) !important; }
.text-due { color: var(--danger) !important; }
.table > :not(caption) > * > * { padding: .65rem .6rem; }

/* ---------- Stat cards (simple) ---------- */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; height: 100%; }
.stat small { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat strong { font-size: 1.5rem; font-weight: 700; }
.stat .stat-icon { font-size: 1.2rem; color: var(--brand); }

/* ---------- Dashboard tappable cards ---------- */
.dash-section { font-weight: 700; color: #374151; margin: 6px 2px 10px; }
.dash-card { position: relative; display: block; background: var(--panel); border: 1px solid var(--line);
    border-radius: 14px; padding: 16px 16px 14px; text-decoration: none; color: var(--ink); height: 100%; transition: box-shadow .15s, transform .15s; }
.dash-card:hover { box-shadow: 0 8px 22px rgba(0,0,0,.07); transform: translateY(-2px); }
.dash-card .dc-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.dash-card .dc-label { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.dash-card .dc-icon { position: absolute; top: 14px; right: 14px; color: var(--brand); font-size: 1.1rem; }
.dash-card .dc-chev { position: absolute; bottom: 10px; right: 12px; color: #cbd5e1; font-size: .9rem; }

/* ---------- Member cards (list) ---------- */
.m-card { position: relative; display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line);
    border-radius: 16px; padding: 16px; overflow: hidden; height: 100%; }
.m-card::before { content: ""; position: absolute; left: 0; bottom: 0; width: 120px; height: 120px;
    background: radial-gradient(circle at 0 100%, rgba(14,165,233,.12), transparent 70%); pointer-events: none; }
.m-avatar { width: 60px; height: 60px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
    background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; }
.m-card { transition: box-shadow .15s, transform .15s; }
.m-card:hover { box-shadow: 0 10px 26px rgba(0,0,0,.08); transform: translateY(-2px); }
.m-card-link { position: absolute; inset: 0; z-index: 1; border-radius: 16px; }
.m-body { flex: 1; min-width: 0; position: relative; }
.m-row { display: flex; justify-content: space-between; gap: 8px; }
.m-k { color: var(--brand); font-size: .72rem; font-weight: 600; }
.m-v { font-weight: 600; }
.m-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; position: relative; z-index: 2; }
.m-actions a, .m-actions button { flex: 1; min-width: 64px; border: 0; background: none; color: var(--brand); text-decoration: none;
    display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .66rem; padding: 4px 2px; border-radius: 8px; }
.m-actions a:hover, .m-actions button:hover { background: #eaf4fc; }
.m-actions i { font-size: 1.05rem; }
.m-actions .a-danger { color: var(--danger); }
.m-del { border: 0; background: none; color: #9ca3af; padding: 2px 4px; line-height: 1; flex-shrink: 0; position: relative; z-index: 2; }
.m-del:hover { color: var(--danger); }

/* ---------- Member ID card (QR) ---------- */
.member-card-wrap { display: flex; flex-direction: column; align-items: center; }
.member-card { width: 420px; max-width: 100%; border-radius: 16px; overflow: hidden; color: #fff;
    background: linear-gradient(135deg, #0ea5e9, #1e3a8a); box-shadow: 0 16px 40px rgba(19,112,196,.3); }
.mc-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0,0,0,.15); }
.mc-gym { font-weight: 700; } .mc-label { font-size: .7rem; letter-spacing: .12em; opacity: .85; }
.mc-body { display: flex; align-items: center; gap: 14px; padding: 16px; }
.mc-photo { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; border: 2px solid rgba(255,255,255,.6); }
.mc-photo-empty { display: inline-flex; align-items: center; justify-content: center; background: rgba(255,255,255,.18); font-size: 2rem; }
.mc-info { flex: 1; min-width: 0; }
.mc-name { font-size: 1.15rem; font-weight: 700; } .mc-code { opacity: .9; letter-spacing: .05em; }
.mc-meta { font-size: .78rem; opacity: .85; margin-top: 4px; }
.mc-qr { background: #fff; border-radius: 10px; padding: 6px; width: 84px; height: 84px; }
.mc-foot { padding: 8px 16px; background: rgba(0,0,0,.15); font-size: .72rem; opacity: .9; }

/* ---------- Login ---------- */
.login-body { background: linear-gradient(135deg, #0ea5e9, #1e3a8a); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-panel { width: 100%; max-width: 380px; border: none; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.login-logo { width: 60px; height: 60px; border-radius: 16px; background: var(--brand); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.8rem; }
.avatar { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: #e1effb;
    display: inline-flex; align-items: center; justify-content: center; color: var(--brand); font-size: 1.6rem; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav { display: none; }
@media (max-width: 991px) {
    .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: #fff;
        border-top: 1px solid var(--line); padding: 4px 4px env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
    .bottom-nav a, .bottom-nav button { flex: 1; border: 0; background: none; color: var(--muted); text-decoration: none;
        display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px; font-size: .68rem; border-radius: 12px; }
    .bottom-nav a i, .bottom-nav button i { font-size: 1.25rem; }
    .bottom-nav a.active { color: var(--brand); background: #e1effb; }
    .bottom-nav .bn-accent { color: #fff; background: var(--brand); margin: 2px; }
    .app-content { padding: 14px 14px 80px; }
    .stat strong { font-size: 1.25rem; }
}
@media (max-width: 575px) {
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .nav-tabs .nav-link { white-space: nowrap; }
    .dash-card .dc-value { font-size: 1.4rem; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .offcanvas, .bottom-nav, .d-print-none, .app-content > .alert { display: none !important; }
    .app-shell, .app-main, .app-content { display: block !important; margin: 0 !important; padding: 0 !important; }
    .panel, .member-card { box-shadow: none !important; }
    .member-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body { background: #fff !important; }
}

/* ---------- Member multi-picker ---------- */
.member-pick { max-height: 230px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.mp-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; margin: 0; }
.mp-item:hover { background: #eaf4fc; }
.mp-item input { margin: 0; }
.mp-item small { color: var(--muted); }

/* ---------- Select2 sizing ---------- */
.select2-dropdown { min-width: 220px; }
.select2-container--bootstrap-5 .select2-results__option { white-space: nowrap; }
.select2-container--bootstrap-5 .select2-selection { min-height: calc(1.5em + .5rem + 2px); }
.select2-container { min-width: 120px; }

/* ---------- Collapsed sidebar (icon rail) ---------- */
@media (min-width: 992px) {
    body.nav-collapsed .sidebar { width: 62px; padding: 8px 6px; }
    body.nav-collapsed .sidebar .brand span,
    body.nav-collapsed .sidebar nav a span,
    body.nav-collapsed .nav-sec-head,
    body.nav-collapsed .nav-section { display: none; }
    body.nav-collapsed .nav-sec.collapsed .nav-sec-items { display: block; } /* show all icons in the rail */
    body.nav-collapsed .sidebar nav a { justify-content: center; padding: 8px 0; margin-bottom: 0; }
    body.nav-collapsed .sidebar nav a i { width: auto; font-size: 1.2rem; }
    body.nav-collapsed .brand { justify-content: center; padding: 4px 0 8px; }
    body.nav-collapsed .brand-logo-lg, body.nav-collapsed .brand-logo { width: 38px; height: 38px; }
}
