:root {
    --cyclex-green: #2e7d32;
    --cyclex-green-dark: #1b5e20;
    --cyclex-green-light: #e8f5e9;
    --text: #1c1c1c;
    --muted: #6b7280;
    --border: #d9e6da;
    --danger: #c0392b;
    --warning: #b8860b;
    --sidebar-width: 230px;
    /* Fixed accents layered on top of the (theme-configurable) three colors
       above — used for the ring/gauge gradient sweep. Not admin-editable;
       kept as a consistent brand accent regardless of primary color choice. */
    --cx-forest: #0d2818;
    --cx-sprout: #6fcf73;
    --cx-gold: #e0af2e;
    /* Structural surface colors — overridden wholesale by .theme-dark
       (admin panel only; the member area never gets this class) so the
       same component CSS below works unmodified in both themes. */
    --page-bg: #fafdfb;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --sidebar-bg: var(--cyclex-green-dark);
    --alert-error-bg: #fdecea;
    --alert-success-bg: var(--cyclex-green-light);
    --alert-warning-bg: #fef8e7;
    --pill-gray-bg: #f0f0f0;
    --row-hover-bg: #fafdfb;
}

/* Dark admin theme — applied via class="admin-shell theme-dark" in
   admin_header.php only. Redefines the same surface variables every
   component already uses, so nothing below needs a duplicate dark ruleset. */
.theme-dark {
    --page-bg: #0b0f1a;
    --card-bg: #161c2c;
    --input-bg: #1c2437;
    --text: #e7eaf2;
    --muted: #97a1b8;
    --border: #29314a;
    --sidebar-bg: #0a0e17;
    --alert-error-bg: rgba(239,68,68,0.12);
    --alert-success-bg: rgba(111,207,115,0.12);
    --alert-warning-bg: rgba(224,175,46,0.12);
    --pill-gray-bg: rgba(255,255,255,0.08);
    --row-hover-bg: rgba(255,255,255,0.03);
    --cyclex-green-light: rgba(111,207,115,0.14);
    --accent-bright: #8be890;
    background: var(--page-bg);
    color: var(--text);
}

.theme-dark h1, .theme-dark h2, .theme-dark h3 { color: #f2f4f8; }
.theme-dark .admin-topbar { background: var(--card-bg); border-bottom-color: var(--border); }
.theme-dark table th { color: var(--muted); }
.theme-dark input, .theme-dark select, .theme-dark textarea { color: var(--text); }
.theme-dark ::placeholder { color: #5b6478; }
.theme-dark .alert-success, .theme-dark .pill-green, .theme-dark .widget-trend.trend-ok { color: var(--accent-bright); }
.theme-dark .card > h2, .theme-dark .card > h3 { color: #f2f4f8; }
.theme-dark a:not(.btn):not(.support-bubble) { color: var(--accent-bright); }
tr.overdue-row { background: var(--alert-error-bg); }
.overdue-label { color: var(--danger); font-weight: 600; font-size: 12px; }
.theme-dark .overdue-label, .theme-dark .alert-error, .theme-dark .pill-red, .theme-dark .widget-trend.trend-alert { color: #f87171; }
.theme-dark .alert-warning, .theme-dark .pill-amber, .theme-dark .widget-trend.trend-warn { color: #e0af2e; }
.theme-dark .admin-topbar .admin-topbar-user a { color: var(--accent-bright); }
.theme-dark .stat-box .value { color: var(--accent-bright); }
.theme-dark .tabs-nav button:hover, .theme-dark .tabs-nav button.tab-active { color: var(--accent-bright); border-bottom-color: var(--accent-bright); }

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    color: var(--text);
    background: var(--page-bg);
}

a { color: var(--cyclex-green-dark); }

.container { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* ===== Public / member site chrome ===== */
.site-header { background: var(--cyclex-green-dark); color: #fff; }
.header-inner { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.logo { color: #fff; font-weight: 700; font-size: 22px; text-decoration: none; letter-spacing: 1px; }
nav a { color: #e8f5e9; text-decoration: none; margin-left: 16px; font-size: 14px; }
nav a:hover { color: #fff; text-decoration: underline; }

main.container { padding: 30px 20px 60px; min-height: 70vh; }

.site-footer { background: var(--cyclex-green-dark); color: #d7e9d8; text-align: center; padding: 20px 0; font-size: 13px; }

/* ===== Admin dashboard shell (sidebar layout) ===== */
.admin-shell {
    display: flex; min-height: 100vh; align-items: flex-start;
    background: var(--page-bg); gap: 14px; padding: 14px;
}

.admin-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background:
        radial-gradient(140% 90% at 0% 0%, rgba(255,255,255,0.05), transparent 60%),
        var(--sidebar-bg);
    color: #e8f5e9;
    padding-bottom: 20px;
    border-radius: 18px;
    box-shadow: 0 12px 32px -14px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
    min-height: calc(100vh - 28px);
    overflow: hidden;
}
/* Logo/header row and the topbar are given the SAME explicit height, both
   flush against the top of their own column (no parent padding above
   either one) — that's what keeps their bottom borders in a straight
   line across the full width, instead of drifting apart based on each
   one's own font-size/padding math. */
.admin-sidebar .admin-logo {
    height: var(--header-height, 64px); box-sizing: border-box;
    color: #fff; font-weight: 700; font-size: 20px; letter-spacing: 1px;
    text-decoration: none; padding: 0 20px; display: flex; align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.12); margin: 0 0 14px;
}
.admin-sidebar .admin-nav-section { padding: 16px 20px 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: rgba(232,245,233,0.45); }
.admin-sidebar a {
    display: flex; align-items: center; gap: 10px; margin: 2px 10px; padding: 9px 12px; color: #cfe8d1;
    text-decoration: none; font-size: 14px; border-radius: 10px; border-left: none; transition: background .15s ease, color .15s ease;
}
.admin-sidebar a .nav-icon { font-size: 15px; flex-shrink: 0; width: 18px; text-align: center; opacity: .85; }
.admin-sidebar a .nav-label { flex: 1; min-width: 0; }
.admin-sidebar a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.admin-sidebar a.active {
    background: linear-gradient(90deg, rgba(255,255,255,0.14), rgba(255,255,255,0.04));
    color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-bright, var(--cyclex-green));
}
.admin-sidebar a.active .nav-icon { opacity: 1; color: var(--accent-bright, var(--cyclex-green)); }

.admin-main {
    flex: 1; min-width: 0; background: var(--card-bg); border-radius: 18px; overflow: hidden;
    box-shadow: 0 12px 32px -18px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03);
}
.admin-topbar {
    height: var(--header-height, 64px); box-sizing: border-box;
    background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0 28px;
    display: flex; justify-content: space-between; align-items: center;
}
.admin-topbar .admin-topbar-user { font-size: 14px; color: var(--muted); margin-left: auto; }
.admin-topbar .admin-topbar-user a { color: var(--cyclex-green-dark); text-decoration: none; margin-left: 12px; }
.admin-content { padding: 28px; max-width: 1200px; }

.hamburger-btn {
    display: none; background: none; border: none; cursor: pointer; padding: 8px;
    margin: 0; font-size: 20px; color: var(--text); line-height: 1; border-radius: 6px;
}
.hamburger-btn:hover { background: var(--row-hover-bg); }
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150;
}
.sidebar-backdrop.is-open { display: block; }

@media (max-width: 860px) {
    .hamburger-btn { display: inline-flex; align-items: center; justify-content: center; }
    .admin-shell { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
    .admin-main { border-radius: 0; box-shadow: none; }
    .admin-sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; min-height: 100vh; z-index: 200; width: 260px;
        transform: translateX(-100%); transition: transform .25s ease; box-shadow: 4px 0 24px rgba(0,0,0,0.3);
        padding-bottom: 20px; overflow-y: auto; border-radius: 0 18px 18px 0;
    }
    .admin-sidebar.is-open { transform: translateX(0); }
    .admin-sidebar .admin-logo { height: 64px; }
    .admin-sidebar .admin-nav-section { display: block; }
    .admin-sidebar-scroll { display: block; overflow-x: visible; }
    .admin-sidebar a {
        flex-direction: row; gap: 10px; padding: 9px 20px; border-left: 3px solid transparent; border-bottom: none;
        white-space: normal; font-size: 14px;
    }
    .admin-sidebar a .nav-icon { font-size: 15px; }
    .admin-sidebar a.active { border-left-color: var(--accent-bright, var(--cyclex-green)); border-bottom: none; }
    .admin-content { padding: 16px; }
    .admin-topbar { padding: 0 16px; height: 52px; }
}

/* ===== Shared components ===== */
h1, h2, h3 { color: var(--cyclex-green-dark); }
h1 { font-size: 24px; margin-bottom: 6px; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-box { background: var(--cyclex-green-light); border-radius: 10px; padding: 16px; }
.stat-box .label { font-size: 13px; color: var(--muted); }
.stat-box .value { font-size: 24px; font-weight: 700; color: var(--cyclex-green-dark); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
tbody tr:hover { background: var(--row-hover-bg); }

form label { display: block; margin-top: 12px; font-size: 14px; font-weight: 600; }
input, select, textarea {
    width: 100%; padding: 10px; margin-top: 4px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 14px; font-family: inherit; background: var(--input-bg); color: var(--text);
}
input[type=color] { padding: 4px; height: 42px; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyclex-green); }

button, .btn {
    display: inline-block; margin-top: 16px; padding: 10px 20px; background: var(--cyclex-green);
    color: var(--on-accent-text, #fff); border: none; border-radius: 6px; cursor: pointer; font-size: 14px; text-decoration: none;
}
button:hover, .btn:hover { background: var(--cyclex-green-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a3382d; }

.alert { padding: 12px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: var(--alert-error-bg); color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: var(--alert-success-bg); color: var(--cyclex-green-dark); border: 1px solid #c8e6c9; }
.alert-warning { background: var(--alert-warning-bg); color: var(--warning); border: 1px solid #f5e2a3; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-green { background: var(--cyclex-green-light); color: var(--cyclex-green-dark); }
.pill-red { background: var(--alert-error-bg); color: var(--danger); }
.pill-amber { background: var(--alert-warning-bg); color: var(--warning); }
.pill-gray { background: var(--pill-gray-bg); color: var(--muted); }

.progress-bar { background: #eee; border-radius: 6px; overflow: hidden; height: 20px; }
.progress-bar-fill { background: var(--cyclex-green); height: 100%; text-align: center; color: #fff; font-size: 12px; line-height: 20px; }

/* ===== Vital-sign hero cards (Cycle Ring + Rate Gauge) ===== */
.hero-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.vital-card {
    position: relative;
    border-radius: 16px;
    padding: 16px;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 10px 30px -12px rgba(13,40,24,0.35);
    transition: transform .25s ease, box-shadow .25s ease;
}
.vital-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px -14px rgba(13,40,24,0.45); }
.vital-card:active { transform: translateY(-1px) scale(.99); }

.vital-card.ring-theme {
    background:
        linear-gradient(rgba(0,0,0,0.38), rgba(0,0,0,0.38)),
        radial-gradient(120% 140% at 15% -10%, rgba(255,255,255,0.16), transparent 55%),
        linear-gradient(135deg, var(--cyclex-green) 0%, var(--cyclex-green-dark) 100%);
}
.vital-card.gauge-theme {
    background:
        radial-gradient(120% 140% at 85% -10%, rgba(224,175,46,0.18), transparent 55%),
        linear-gradient(135deg, #14351f 0%, var(--cx-forest) 100%);
}

.vital-eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.14);
    padding: 5px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 600; letter-spacing: .3px;
    backdrop-filter: blur(4px);
}

.vital-title { font-size: 14px; font-weight: 700; margin: 10px 0 2px; color: #fff; }
.vital-subtitle { font-size: 12px; color: rgba(255,255,255,0.85); margin: 0 0 2px; }

.ring-wrap { display: flex; justify-content: center; margin: 6px 0 4px; }
.ring-wrap svg { display: block; }
.ring-track { stroke: rgba(255,255,255,0.18); }
.ring-fill {
    stroke: url(#cxRingGradient);
    stroke-linecap: round;
    transition: stroke-dashoffset 1.1s cubic-bezier(.16,1,.3,1);
}
.ring-center-value { font-size: 30px; font-weight: 800; fill: #fff; font-variant-numeric: tabular-nums; }
.ring-center-label { font-size: 10.5px; fill: rgba(255,255,255,0.65); letter-spacing: .5px; }

.vital-badge {
    display: inline-block; margin: 6px auto 0; padding: 4px 14px;
    background: rgba(255,255,255,0.16); border-radius: 999px;
    font-size: 12px; font-weight: 700;
}
.vital-badge-row { text-align: center; }

.vital-delta {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.10); border-radius: 10px; padding: 9px 12px;
    margin-top: 10px; font-size: 13px;
}
.vital-delta .delta-icon {
    width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
}
.vital-delta strong { display: block; font-size: 13px; }
.vital-delta span.sub { color: rgba(255,255,255,0.65); font-size: 11.5px; }

.vital-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.14);
    font-size: 12px; color: rgba(255,255,255,0.75);
}
.vital-footer a { color: #fff; text-decoration: none; font-weight: 600; }
.vital-footer a:hover { text-decoration: underline; }

/* Gauge */
.gauge-wrap { display: flex; justify-content: center; margin: 2px 0 0; }
.gauge-arc-track { stroke: rgba(255,255,255,0.14); }
.gauge-arc-fill {
    stroke: url(#cxGaugeGradient);
    stroke-linecap: round;
    transition: stroke-dasharray 1.1s cubic-bezier(.16,1,.3,1);
}
.gauge-needle { stroke: var(--cx-gold); transition: transform 1.1s cubic-bezier(.16,1,.3,1); transform-origin: 100px 100px; }
.gauge-needle-hub { fill: var(--cx-gold); }
.gauge-value { font-size: 26px; font-weight: 800; fill: #fff; font-variant-numeric: tabular-nums; }
.gauge-unit { font-size: 10.5px; fill: rgba(255,255,255,0.6); letter-spacing: .5px; }

.gauge-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.14); }
.gauge-stats div { text-align: center; }
.gauge-stats strong { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.gauge-stats span { font-size: 10.5px; color: rgba(255,255,255,0.6); letter-spacing: .4px; text-transform: uppercase; }

/* Entrance animation runs automatically via CSS — no JS dependency, so
   cards are never permanently invisible if a script fails to load. JS is
   only used for the ring/gauge/counter "reveal" flourish, which already
   degrades to a correct static value on its own (see helpers.php). */
@keyframes cxCardEnter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.vital-card, .widget-tile { animation: cxCardEnter .5s ease both; }
.hero-row .vital-card:nth-child(1) { animation-delay: .03s; }
.hero-row .vital-card:nth-child(2) { animation-delay: .12s; }
.hero-row .vital-card:nth-child(3) { animation-delay: .21s; }
.widget-grid .widget-tile:nth-child(1) { animation-delay: .18s; }
.widget-grid .widget-tile:nth-child(2) { animation-delay: .24s; }
.widget-grid .widget-tile:nth-child(3) { animation-delay: .30s; }
.widget-grid .widget-tile:nth-child(4) { animation-delay: .36s; }
.widget-grid .widget-tile:nth-child(5) { animation-delay: .42s; }
.widget-grid .widget-tile:nth-child(6) { animation-delay: .48s; }

@media (prefers-reduced-motion: reduce) {
    .vital-card, .widget-tile { animation: none; }
    .ring-fill, .gauge-needle { transition: none !important; }
}

/* ===== Widget tiles (native-widget-style stat cards) ===== */
.widget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.widget-tile {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: transform .2s ease, box-shadow .2s ease, opacity .5s ease;
}
.widget-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(13,40,24,0.25); }
.widget-icon-chip {
    width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 16px; margin-bottom: 10px;
}
.widget-value { font-size: 22px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.widget-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.widget-trend { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; margin-top: 8px; padding: 2px 8px; border-radius: 999px; }
.widget-trend.trend-ok { background: var(--cyclex-green-light); color: var(--cyclex-green-dark); }
.widget-trend.trend-warn { background: var(--alert-warning-bg); color: var(--warning); }
.widget-trend.trend-alert { background: var(--alert-error-bg); color: var(--danger); }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--cyclex-green); outline-offset: 2px;
}

/* Colored icon chips — translucent tints so the emoji icon's own color
   still reads through, and each works on both the light and dark theme
   without needing separate dark-mode variants. */
.icon-blue   { background: rgba(59,130,246,0.15); }
.icon-purple { background: rgba(139,92,246,0.15); }
.icon-orange { background: rgba(245,158,11,0.15); }
.icon-red    { background: rgba(239,68,68,0.15); }
.icon-green  { background: rgba(16,185,129,0.15); }
.icon-pink   { background: rgba(236,72,153,0.15); }
.icon-teal   { background: rgba(6,182,212,0.15); }
.icon-gold   { background: rgba(224,175,46,0.18); }

/* ===== Tabs ===== */
.tabs-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tabs-nav button {
    background: none; border: none; margin-top: 0; padding: 11px 18px; font-weight: 700; font-size: 13.5px;
    color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; border-radius: 0; white-space: nowrap;
}
.tabs-nav button:hover { color: var(--cyclex-green); background: none; }
.tabs-nav button.tab-active { color: var(--cyclex-green); border-bottom-color: var(--cyclex-green); }
.tab-panel { display: none; }
.tab-panel.tab-active { display: block; }
/* No-JS fallback: the first tab's panel ships with .tab-active already in
   the raw HTML, so it's fully visible without any script running — only
   the ability to switch tabs is JS-dependent, never the content itself. */

/* ===== Account Balance gradient card + Referral box ===== */
.balance-card {
    border-radius: 20px;
    padding: 22px;
    color: #fff;
    background:
        radial-gradient(130% 160% at 10% -20%, rgba(255,255,255,0.18), transparent 55%),
        linear-gradient(135deg, var(--cyclex-green) 0%, var(--cyclex-green-dark) 70%, var(--cx-forest) 100%);
    box-shadow: 0 10px 30px -12px rgba(13,40,24,0.35);
    margin-bottom: 18px;
}
.balance-card-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.balance-card-pill { background: rgba(255,255,255,0.18); padding: 3px 10px; border-radius: 999px; font-size: 11px; letter-spacing: .5px; }
.balance-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,0.14); font-size: 14px; }
.balance-row:last-of-type { border-bottom: none; }
.balance-row-label { color: rgba(255,255,255,0.85); }
.balance-row-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-actions { display: flex; gap: 10px; margin-top: 16px; }
.balance-action {
    flex: 1; text-align: center; padding: 11px 10px; border-radius: 10px; font-size: 13.5px; font-weight: 700;
    text-decoration: none; transition: transform .15s ease, background .15s ease;
}
.balance-action:active { transform: scale(.97); }
.balance-action-primary { background: #fff; color: var(--cyclex-green-dark); }
.balance-action-primary:hover { background: #eefaf0; }
.balance-action-ghost { background: rgba(255,255,255,0.14); color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.balance-action-ghost:hover { background: rgba(255,255,255,0.22); }

.referral-box { margin-bottom: 18px; }
.referral-box-label { font-size: 13px; font-weight: 700; color: var(--cyclex-green-dark); margin-bottom: 8px; }
.referral-box-row { display: flex; gap: 8px; }
.referral-box-row input {
    flex: 1; margin-top: 0; background: #fafdfb; font-family: monospace; font-size: 13px; color: var(--muted);
}
.referral-box-row button {
    margin-top: 0; padding: 10px 18px; white-space: nowrap; flex-shrink: 0;
}
.referral-box-sub { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }

/* Widget tile corner accent — small decorative blob, subtle, theme-colored */
.widget-tile { position: relative; overflow: hidden; }
.widget-tile::after {
    content: ''; position: absolute; top: -18px; right: -18px; width: 46px; height: 46px;
    background: var(--cyclex-green-light); border-radius: 50%; opacity: .6; z-index: 0;
}
.widget-tile > * { position: relative; z-index: 1; }

/* ===== Breadcrumb ===== */
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--cyclex-green); }
.breadcrumb .crumb-current { color: var(--cyclex-green); font-weight: 600; }
.page-title { font-size: 22px; font-weight: 800; margin: 2px 0 24px; }

/* ===== Wallet hero (total balance + sub-wallets) ===== */
.wallet-hero-heading { font-size: 30px; font-weight: 800; margin: 0 0 8px; }
.wallet-hero-heading .accent { color: var(--cyclex-green); }
.wallet-hero-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; max-width: 520px; }

.total-balance-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; padding: 24px;
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px;
    margin-bottom: 18px;
}
.total-balance-main .tb-label { font-size: 11.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.total-balance-main .tb-value { font-size: 38px; font-weight: 800; color: var(--cyclex-green); font-variant-numeric: tabular-nums; margin: 4px 0; }
.total-balance-main .tb-meta { font-size: 12.5px; color: var(--muted); }
.total-balance-sub { display: flex; gap: 12px; flex-wrap: wrap; }
.sub-wallet-box {
    background: var(--page-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; min-width: 130px;
}
.sub-wallet-box .sw-label { font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.sub-wallet-box .sw-value { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ===== Action cards (Deposit / Invest / Withdraw style) ===== */
.action-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.action-card {
    display: flex; align-items: center; gap: 14px; background: var(--card-bg);
    border: 1px solid var(--border); border-left: 3px solid var(--action-color, var(--cyclex-green));
    border-radius: 12px; padding: 16px 18px; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease;
}
.action-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(0,0,0,0.3); }
.action-card:active { transform: translateY(0) scale(.99); }
.action-card-icon {
    width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
    background: var(--action-color, var(--cyclex-green)); color: var(--action-icon-color, #fff);
    display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.action-card-title { font-weight: 700; font-size: 14.5px; color: var(--text); }
.action-card-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.secondary-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.secondary-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.secondary-card .sc-label { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.secondary-card .sc-value { font-size: 24px; font-weight: 800; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.secondary-card .sc-link { font-size: 13px; font-weight: 600; color: var(--cyclex-green); text-decoration: none; }
.secondary-card .sc-link:hover { text-decoration: underline; }

/* ===== Floating support bubble ===== */
.support-bubble {
    position: fixed; bottom: 24px; right: 24px; width: 54px; height: 54px; border-radius: 50%;
    background: var(--cyclex-green); color: var(--on-accent-text, #0a1f1c); display: flex; align-items: center; justify-content: center;
    font-size: 22px; text-decoration: none; box-shadow: 0 8px 24px -6px rgba(0,0,0,0.5); z-index: 100;
    transition: transform .2s ease;
}
.support-bubble:hover { transform: scale(1.08); }
.support-bubble:active { transform: scale(.96); }

/* ===== Premium package cards — always 2 per row on mobile, more on wider
   screens; each card gets its own accent color + icon (cycled from a
   palette), not one uniform theme color. ===== */
.pkg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 24px; }
@media (min-width: 720px) {
    .pkg-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
.pkg-card {
    position: relative; overflow: hidden; text-align: center;
    background: var(--card-bg); border: 1px solid var(--border);
    border-top: 4px solid var(--pkg-color, var(--cyclex-green));
    border-radius: 14px; padding: 18px 14px;
    transition: transform .2s ease, box-shadow .2s ease;
}
.pkg-card::before {
    content: ''; position: absolute; top: -30px; right: -30px; width: 90px; height: 90px;
    background: var(--pkg-color, var(--cyclex-green)); opacity: .12; border-radius: 50%;
}
.pkg-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px -14px rgba(0,0,0,0.35); }
.pkg-icon-chip {
    position: relative; z-index: 1; width: 46px; height: 46px; margin: 0 auto 10px;
    border-radius: 50%; background: var(--pkg-color, var(--cyclex-green)); color: var(--pkg-icon-color, #fff);
    display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.pkg-card h3 { position: relative; z-index: 1; margin: 0 0 2px; font-size: 15.5px; }
.pkg-card .pkg-amount { position: relative; z-index: 1; font-size: 11.5px; color: var(--muted); margin: 0 0 10px; text-transform: uppercase; letter-spacing: 1px; }
.pkg-badge {
    position: relative; z-index: 1; display: inline-block; margin-bottom: 10px; padding: 3px 12px;
    border-radius: 999px; font-size: 12px; font-weight: 700;
    background: var(--pkg-color, var(--cyclex-green)); color: var(--pkg-icon-color, #fff); opacity: .92;
}
.pkg-card .pkg-formula { position: relative; z-index: 1; font-size: 12.5px; color: var(--muted); margin: 0; }
.pkg-card .pkg-profit { position: relative; z-index: 1; font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.pkg-card form { position: relative; z-index: 1; }
.pkg-card button {
    background: var(--pkg-color, var(--cyclex-green)); color: var(--pkg-icon-color, #fff);
}
.pkg-card button:hover { filter: brightness(0.9); }

@media (max-width: 860px) {
    .pkg-card { padding: 14px 10px; }
    .pkg-icon-chip { width: 38px; height: 38px; font-size: 16px; margin-bottom: 8px; }
    .pkg-card h3 { font-size: 13.5px; }
    .pkg-card .pkg-amount { font-size: 10px; }
    .pkg-badge { font-size: 10.5px; padding: 2px 9px; }
    .pkg-card .pkg-formula, .pkg-card .pkg-profit { font-size: 11px; }
    .pkg-card button { font-size: 12.5px; padding: 8px 10px; }
}

@media (max-width: 860px) {
    /* Stat tiles stay in a horizontal row on mobile instead of stacking
       to one column — up to 3 per row, tighter padding/type to fit.
       (Placed here, after the base .widget-grid rule above, deliberately
       — an earlier attempt at this override sat before the base rule in
       the file and was silently losing the cascade regardless of the
       media query, since same-specificity rules resolve by source order.) */
    .widget-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .widget-tile { padding: 10px; border-radius: 12px; }
    .widget-icon-chip { width: 26px; height: 26px; font-size: 12px; margin-bottom: 6px; border-radius: 8px; }
    .widget-value { font-size: 16px; }
    .widget-label { font-size: 10.5px; line-height: 1.25; }
    .widget-trend { font-size: 9.5px; padding: 1px 6px; }

    /* Wide data tables (referral commission/rebate history etc.) don't fit
       mobile width — scroll horizontally within their own card instead of
       forcing the whole page to scroll sideways. */
    .card { overflow-x: auto; }
    table { min-width: 480px; }
}

/* ===== Live chat widget ===== */
.chat-panel {
    position: fixed; bottom: 92px; right: 24px; width: 340px; max-width: calc(100vw - 32px);
    height: 460px; max-height: calc(100vh - 130px); background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: 0 16px 48px -10px rgba(0,0,0,0.5); z-index: 110;
    display: flex; flex-direction: column; overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-panel-header {
    background: var(--cyclex-green); color: var(--on-accent-text, #fff); padding: 14px 16px;
    display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14.5px; flex-shrink: 0;
}
.chat-panel-close { background: none; border: none; color: inherit; font-size: 16px; cursor: pointer; padding: 4px; margin: 0; line-height: 1; }
.chat-panel-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-empty-state { color: var(--muted); font-size: 13px; text-align: center; margin-top: 20px; }
.chat-bubble {
    max-width: 80%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.4; white-space: pre-line; word-break: break-word;
}
.chat-bubble.from-user { align-self: flex-end; background: var(--cyclex-green); color: var(--on-accent-text, #fff); border-bottom-right-radius: 4px; }
.chat-bubble.from-admin { align-self: flex-start; background: var(--page-bg); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-bubble-time { font-size: 10px; opacity: .7; margin-top: 3px; display: block; }
.chat-panel-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-panel-input textarea {
    flex: 1; margin-top: 0; resize: none; max-height: 80px; font-size: 13.5px; padding: 9px 10px;
}
.chat-panel-input button {
    margin-top: 0; width: 40px; height: 40px; padding: 0; flex-shrink: 0; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.chat-status-banner { font-size: 11.5px; text-align: center; padding: 6px; color: var(--muted); background: var(--page-bg); border-bottom: 1px solid var(--border); }

@media (max-width: 480px) {
    .chat-panel { right: 16px; bottom: 84px; width: calc(100vw - 32px); height: calc(100vh - 160px); }
}

/* ===== Referral tree (lazy-loaded, accordion-style) ===== */
.ref-tree { font-size: 14px; }
.ref-tree-node-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px;
}
.ref-tree-node-row:hover { background: var(--row-hover-bg); }
.ref-tree-toggle {
    width: 22px; height: 22px; flex-shrink: 0; border-radius: 6px; border: 1px solid var(--border);
    background: var(--card-bg); color: var(--cyclex-green); font-size: 11px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; margin: 0; padding: 0;
}
.ref-tree-toggle:hover { background: var(--cyclex-green-light); }
.ref-tree-toggle.is-leaf { visibility: hidden; cursor: default; }
.ref-tree-avatar {
    width: 28px; height: 28px; border-radius: 50%; background: var(--cyclex-green-light); color: var(--cyclex-green-dark);
    display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; text-transform: uppercase;
}
.ref-tree-name { font-weight: 600; }
.ref-tree-meta { font-size: 11.5px; color: var(--muted); margin-left: 4px; }
.ref-tree-children {
    margin-left: 26px; padding-left: 14px; border-left: 2px solid var(--border);
    display: none;
}
.ref-tree-children.is-open { display: block; }
.ref-tree-loading, .ref-tree-empty { font-size: 12.5px; color: var(--muted); padding: 6px 6px 6px 32px; }
.ref-tree-root-row { font-weight: 700; }
.ref-tree-root-row .ref-tree-avatar { background: var(--cyclex-green); color: var(--on-accent-text, #fff); }
.theme-dark .ref-tree-avatar { color: var(--accent-bright); }
.theme-dark .ref-tree-root-row .ref-tree-avatar { color: var(--on-accent-text, #fff); }

/* ===== Celebration banner (e.g. "investment purchased" congrats) ===== */
.celebrate-banner {
    display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-radius: 16px;
    background:
        linear-gradient(rgba(0,0,0,0.38), rgba(0,0,0,0.38)),
        linear-gradient(135deg, var(--cyclex-green) 0%, var(--cx-gold) 130%);
    color: #fff; margin-bottom: 20px;
    box-shadow: 0 10px 28px -10px rgba(0,0,0,0.35);
    animation: cxCardEnter .5s ease both;
}
.celebrate-banner-icon {
    width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,0.22);
    display: flex; align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0;
}
.celebrate-banner-title { font-weight: 800; font-size: 15.5px; margin: 0 0 2px; }
.celebrate-banner-text { font-size: 13.5px; opacity: .95; margin: 0; }

/* ===== Impersonation banner ===== */
.impersonation-banner {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    background: linear-gradient(135deg, #8a6508 0%, #6b4e06 100%); color: #fff;
    padding: 10px 24px; font-size: 13.5px; font-weight: 600;
}
.impersonation-banner form { margin: 0; }
.impersonation-banner button {
    margin-top: 0; padding: 7px 16px; background: rgba(255,255,255,0.2); color: #fff;
    border: 1px solid rgba(255,255,255,0.4); font-size: 12.5px; font-weight: 700;
}
.impersonation-banner button:hover { background: rgba(255,255,255,0.3); }
@media (max-width: 860px) {
    .impersonation-banner { flex-direction: column; align-items: flex-start; padding: 10px 16px; }
}
