/* ====== RisingJoy Client Portal — design tokens ====== */
:root {
    --cp-bg-page: #eceff4;
    --cp-bg-page-2: #f8fafc;
    --cp-surface: #ffffff;
    --cp-text: #0f172a;
    --cp-text-muted: #475569;
    --cp-border: #e2e8f0;
    --cp-border-strong: #cbd5e1;
    --cp-brand: #fe4401;
    --cp-brand-hover: #ff5a1a;
    --cp-accent: #0005ff;
    /* Portal page-edge accents (pink → indigo), used sparingly behind content */
    --cp-gradient-accent-a: #f869d5;
    --cp-gradient-accent-b: #5650de;
    --cp-header-bg: rgba(8, 10, 18, 0.92);
    --cp-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --cp-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --cp-shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
    --cp-radius: 12px;
    --cp-radius-sm: 8px;
    --cp-font: "Tahoma", "Arial", sans-serif;
    --cp-transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --cp-transition: none;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    body.client-portal {
        background-attachment: scroll;
    }
}

/* ====== Portal shell (authenticated /Clients/*) ====== */
body.client-portal {
    margin: 0;
    min-height: 100vh;
    font-family: var(--cp-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--cp-text);
    background-color: var(--cp-bg-page);
    /* Neutral base + small edge blooms (left / right / bottom) — #F869D5 → #5650DE */
    background-image:
        radial-gradient(
            ellipse 130% min(36vh, 220px) at 50% 100%,
            rgba(248, 105, 213, 0.16) 0%,
            rgba(86, 80, 222, 0.12) 42%,
            transparent 68%
        ),
        radial-gradient(
            ellipse min(38vw, 300px) 100% at -10% 48%,
            rgba(248, 105, 213, 0.26) 0%,
            rgba(248, 105, 213, 0.05) 48%,
            transparent 70%
        ),
        radial-gradient(
            ellipse min(38vw, 300px) 100% at 110% 52%,
            rgba(86, 80, 222, 0.24) 0%,
            rgba(86, 80, 222, 0.05) 48%,
            transparent 70%
        ),
        linear-gradient(180deg, var(--cp-bg-page) 0%, var(--cp-bg-page-2) 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-attachment: fixed;
}

/* ----- Header ----- */
.client-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.client-header__bar {
    background: var(--cp-header-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.client-header__inner {
    max-width: 1320px;
}

.client-header__brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    gap: 16px;
}

.client-brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 8px 0;
    cursor: pointer;
}

.client-brand__logo {
    height: 80px;
    width: auto;
    display: block;
    filter: brightness(1.05);
}

.client-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--cp-radius-sm);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: var(--cp-transition);
}

.client-burger:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
}

.client-burger__line {
    display: block;
    height: 2px;
    width: 100%;
    background: #fff;
    border-radius: 1px;
}

.client-nav-collapse {
    width: 100%;
}

.client-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    padding: 12px 0 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.client-nav__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.client-nav__link {
    display: inline-block;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.78) !important;
    text-decoration: none !important;
    border-radius: 999px;
    transition: var(--cp-transition);
    cursor: pointer;
    position: relative;
}

.client-nav__link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.08);
}

.client-nav__link.is-active {
    color: #fff !important;
    background: linear-gradient(135deg, rgba(254, 68, 1, 0.35) 0%, rgba(0, 5, 255, 0.25) 100%);
    box-shadow: 0 0 0 1px rgba(254, 68, 1, 0.45);
}

.client-nav__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.client-nav__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: var(--cp-transition);
    text-decoration: none !important;
    font-family: var(--cp-font);
}

.client-nav__cta--ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.client-nav__cta--ghost:hover {
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.06);
}

.client-nav__cta--primary {
    background: linear-gradient(135deg, var(--cp-brand) 0%, #e03d00 100%);
    color: #fff !important;
    box-shadow: 0 4px 16px rgba(254, 68, 1, 0.35);
}

.client-nav__cta--primary:hover {
    background: linear-gradient(135deg, var(--cp-brand-hover) 0%, var(--cp-brand) 100%);
    box-shadow: 0 6px 22px rgba(254, 68, 1, 0.45);
    transform: translateY(-1px);
    color: #fff !important;
}

@media (min-width: 992px) {
    .client-header__brand-row {
        min-height: 72px;
    }

    .client-burger {
        display: none !important;
    }

    .client-nav-collapse.collapse {
        display: block !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        visibility: visible !important;
    }

    .client-header__inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 8px 24px;
    }

    .client-header__brand-row {
        min-height: 0;
        width: auto;
        flex: 0 0 auto;
    }

    .client-nav-collapse {
        flex: 1 1 auto;
        width: auto;
    }

    .client-nav {
        flex-wrap: nowrap;
        padding: 0;
        border-top: none;
        justify-content: flex-end;
        gap: 8px 12px;
    }

    .client-nav__list {
        flex: 1 1 auto;
        justify-content: center;
        gap: 2px;
    }

    .client-nav__actions {
        flex: 0 0 auto;
    }
}

@media (max-width: 991px) {
    .client-burger {
        display: flex;
    }

    .client-nav {
        flex-direction: column;
        align-items: stretch;
    }

    .client-nav__list {
        flex-direction: column;
        align-items: stretch;
    }

    .client-nav__link {
        border-radius: var(--cp-radius-sm);
    }

    .client-nav__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .client-nav__cta {
        width: 100%;
    }
}

/* ----- Main & footer ----- */
.client-main {
    min-height: calc(100vh - 180px);
    padding: 32px 0 48px;
}

.client-main__container {
    max-width: 1320px;
}

.client-footer {
    margin-top: auto;
    padding: 20px 0 28px;
    border-top: 1px solid var(--cp-border);
    background: rgba(255, 255, 255, 0.65);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.client-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
    font-size: 13px;
    color: var(--cp-text-muted);
}

.client-footer__copy {
    margin-right: 8px;
}

.client-footer__dot {
    color: var(--cp-border-strong);
}

.client-footer__link {
    color: var(--cp-text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: var(--cp-transition);
    cursor: pointer;
}

.client-footer__link:hover {
    color: var(--cp-brand);
}

/* ----- Page titles ----- */
body.client-portal .section-title {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0f172a;
    margin: 0 0 12px;
    position: relative;
    padding: 12px 18px 18px;
    display: inline-block;
    max-width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius-sm);
    box-shadow: var(--cp-shadow-sm);
}

body.client-portal .section-title::after {
    content: "";
    position: absolute;
    left: 18px;
    bottom: 10px;
    width: 56px;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--cp-brand) 0%, var(--cp-accent) 100%);
}

body.client-portal .profile-header .section-title {
    margin-bottom: 0;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

/* ----- Auth (Login / Register / Forgot — main site layout, dark card) ----- */
.box.auth-page {
    /* Let .box (common.css) black + white text show through; glows sit on top */
    background: transparent !important;
    margin-top: -120px !important;
    padding-top: 160px !important;
    padding-bottom: 80px !important;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.auth-page {
    width: 100%;
    min-height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px 48px;
}

.auth-page::before {
    content: "";
    position: absolute;
    width: 600px;
    height: 600px;
    max-width: 90vw;
    max-height: 90vw;
    top: -120px;
    left: -200px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(254, 68, 1, 0.25) 0%, rgba(254, 68, 1, 0) 70%);
    pointer-events: none;
    z-index: 0;
}

.auth-page::after {
    content: "";
    position: absolute;
    width: 800px;
    height: 800px;
    max-width: 120vw;
    max-height: 120vw;
    bottom: -200px;
    right: -300px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(0, 5, 255, 0.2) 0%, rgba(0, 5, 255, 0) 60%);
    pointer-events: none;
    z-index: 0;
}

.auth-glow-1,
.auth-glow-2 {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    border-radius: 50%;
}

.auth-glow-1 {
    width: 500px;
    height: 500px;
    top: 50%;
    left: 60%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 50% 50%, rgba(0, 63, 255, 0.12) 0%, rgba(0, 0, 0, 0) 50%);
}

.auth-glow-2 {
    width: 300px;
    height: 300px;
    top: 20%;
    right: 10%;
    background: radial-gradient(circle at center, rgba(254, 90, 1, 0.1) 0%, transparent 70%);
}

.auth-container {
    max-width: 460px;
    width: 100%;
    margin: 0 auto;
    padding: 40px;
    background: linear-gradient(160deg, rgba(17, 17, 17, 0.95) 0%, rgba(11, 12, 50, 0.9) 100%);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 80px rgba(0, 5, 255, 0.06);
    position: relative;
    z-index: 1;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.auth-container::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: 13px;
    padding: 1px;
    background: linear-gradient(160deg, rgba(0, 5, 255, 0.3), transparent 40%, transparent 60%, rgba(254, 68, 1, 0.2));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: -1;
}

.auth-container h2 {
    text-align: center;
    margin: 0 0 32px;
    font-weight: 300;
    letter-spacing: 2px;
    font-size: 1.1rem;
    color: #fff;
}

.auth-container h2::after {
    content: "";
    display: block;
    width: 40px;
    height: 3px;
    margin: 12px auto 0;
    border-radius: 2px;
    background: linear-gradient(to right, #fe4401, #0005ff);
}

/* Modal auth overlay (main site _Layout — login / register / forgot) */
.client-auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.client-auth-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.client-auth-overlay__backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    /* Light dim + light blur so page text behind stays readable */
    background: rgba(0, 0, 0, 0.35);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.client-auth-overlay__glow {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    border-radius: 50%;
}

.client-auth-overlay__glow--1 {
    width: min(520px, 90vw);
    height: min(520px, 90vw);
    top: 10%;
    left: 50%;
    transform: translate(-50%, -30%);
    background: radial-gradient(circle at center, rgba(254, 68, 1, 0.1) 0%, transparent 65%);
}

.client-auth-overlay__glow--2 {
    width: min(420px, 80vw);
    height: min(420px, 80vw);
    bottom: -5%;
    right: -8%;
    background: radial-gradient(circle at center, rgba(0, 5, 255, 0.08) 0%, transparent 60%);
}

.client-auth-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    max-height: min(92vh, 900px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.client-auth-container {
    position: relative;
}

/* Frosted glass card: semi-transparent so background shows through slightly */
.client-auth-overlay .auth-container {
    background: linear-gradient(160deg, rgba(17, 17, 17, 0.72) 0%, rgba(11, 12, 50, 0.68) 100%);
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
    backdrop-filter: blur(14px) saturate(1.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 80px rgba(0, 5, 255, 0.05);
}

.client-auth-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}

.client-auth-close:hover,
.client-auth-close:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}

.client-auth-links-sep {
    margin: 0 8px;
    color: rgba(255, 255, 255, 0.35);
    user-select: none;
}

.box.client-auth-page-spacer {
    background: #000;
    min-height: 70vh;
}

/* Portal-only light forms (auth uses rules below with higher specificity on .auth-container) */
body.client-portal .form-group {
    margin-bottom: 20px;
}

body.client-portal .form-group label {
    color: var(--cp-text-muted);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

body.client-portal .form-control {
    background: var(--cp-surface);
    border: 1px solid var(--cp-border);
    color: var(--cp-text);
    height: 44px;
    border-radius: var(--cp-radius-sm);
    font-size: 15px;
    transition: var(--cp-transition);
    box-shadow: var(--cp-shadow-sm);
}

body.client-portal .form-control:focus {
    border-color: rgba(0, 5, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(0, 5, 255, 0.12);
    color: var(--cp-text);
}

body.client-portal .form-control::placeholder {
    color: #94a3b8;
}

/* Read-only text fields only — flatpickr date fields use .client-date-input and match normal inputs */
body.client-portal .form-control[readonly]:not(.client-date-input) {
    background: #f1f5f9;
    color: var(--cp-text-muted);
}

body.client-portal .form-control.client-date-input[readonly] {
    background: var(--cp-surface);
    color: var(--cp-text);
    cursor: pointer;
    opacity: 1;
}

.box.auth-page .auth-container .form-group,
.client-auth-overlay .auth-container .form-group {
    margin-bottom: 20px;
}

.box.auth-page .auth-container .form-group label,
.client-auth-overlay .auth-container .form-group label {
    color: #aaa;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.box.auth-page .auth-container .form-control,
.client-auth-overlay .auth-container .form-control {
    background: rgba(15, 15, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    height: 42px;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-shadow: none;
}

.box.auth-page .auth-container .form-control:focus,
.client-auth-overlay .auth-container .form-control:focus {
    background: rgba(15, 15, 20, 0.9);
    border-color: rgba(0, 5, 255, 0.5);
    color: #fff;
    box-shadow: 0 0 0 2px rgba(0, 5, 255, 0.1), 0 0 12px rgba(0, 5, 255, 0.08);
}

.box.auth-page .auth-container .form-control::placeholder,
.client-auth-overlay .auth-container .form-control::placeholder {
    color: #555;
}

.btn-primary {
    background: linear-gradient(135deg, var(--cp-brand) 0%, #e03d00 100%);
    border: none;
    border-radius: var(--cp-radius-sm);
    height: 44px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff !important;
    transition: var(--cp-transition);
    box-shadow: 0 4px 16px rgba(254, 68, 1, 0.28);
    cursor: pointer;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--cp-brand-hover) 0%, var(--cp-brand) 100%);
    box-shadow: 0 6px 22px rgba(254, 68, 1, 0.38);
    color: #fff !important;
    transform: translateY(-1px);
}

/* ----- Send verification code button (loading) ----- */
.btn.is-loading,
button.is-loading {
    cursor: wait;
    pointer-events: none;
    opacity: 0.92;
}

.btn-send-code__spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid rgba(15, 23, 42, 0.2);
    border-top-color: var(--cp-brand, #fe4401);
    border-radius: 50%;
    animation: btn-send-code-spin 0.7s linear infinite;
}

.client-auth-overlay .btn-send-code__spinner {
    border-color: rgba(15, 23, 42, 0.2);
    border-top-color: var(--cp-brand, #fe4401);
}

@keyframes btn-send-code-spin {
    to {
        transform: rotate(360deg);
    }
}

body.client-portal .btn-outline {
    background: var(--cp-surface);
    border: 1px solid var(--cp-border-strong);
    color: var(--cp-text) !important;
    border-radius: var(--cp-radius-sm);
    height: 44px;
    transition: var(--cp-transition);
    cursor: pointer;
    font-weight: 600;
}

body.client-portal .btn-outline:hover {
    border-color: var(--cp-accent);
    color: var(--cp-accent) !important;
    background: rgba(0, 5, 255, 0.04);
}

.box.auth-page .auth-container .btn-outline,
.client-auth-overlay .auth-container .btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ccc !important;
    border-radius: 6px;
    height: 42px;
    transition: all 0.3s;
    cursor: pointer;
    font-weight: 600;
}

.box.auth-page .auth-container .btn-outline:hover,
.client-auth-overlay .auth-container .btn-outline:hover {
    border-color: rgba(0, 5, 255, 0.5);
    color: #fff !important;
    background: rgba(0, 5, 255, 0.08);
}

.box.auth-page .auth-container .btn-primary,
.client-auth-overlay .auth-container .btn-primary {
    height: 42px;
    border-radius: 6px;
    letter-spacing: 1px;
    font-size: 15px;
}

.captcha-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-row .form-control {
    flex: 1;
}

/* Captcha image: loading / error overlay (login & register modals) */
.captcha-img-wrap {
    position: relative;
    width: 120px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    outline: none;
}

.captcha-img-wrap:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 5, 255, 0.45);
}

.captcha-img-wrap .captcha-img-el {
    display: block;
    width: 120px;
    height: 42px;
    object-fit: contain;
    background: rgba(15, 15, 20, 0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.captcha-img-wrap.is-ready .captcha-img-el {
    opacity: 1;
}

.captcha-loading-panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px;
    background: rgba(15, 15, 20, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    z-index: 2;
    text-align: center;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.captcha-img-wrap.is-ready .captcha-loading-panel {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.captcha-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fe4401;
    border-radius: 50%;
    animation: captcha-spin 0.75s linear infinite;
}

.captcha-status-text {
    font-size: 10px;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.75);
    max-width: 112px;
}

.captcha-status-error {
    display: none;
    color: #f87171;
}

.captcha-img-wrap.is-error .captcha-spinner,
.captcha-img-wrap.is-error .captcha-status-loading {
    display: none;
}

.captcha-img-wrap.is-error .captcha-status-error {
    display: block;
}

.captcha-img-wrap.is-error .captcha-loading-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

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

@media (prefers-reduced-motion: reduce) {
    .captcha-spinner {
        animation: none;
        border-top-color: rgba(255, 255, 255, 0.35);
    }
}

body.client-portal .captcha-row img {
    height: 44px;
    border-radius: var(--cp-radius-sm);
    cursor: pointer;
    border: 1px solid var(--cp-border);
    transition: var(--cp-transition);
}

body.client-portal .captcha-row img:hover {
    border-color: var(--cp-accent);
    box-shadow: 0 0 0 2px rgba(0, 5, 255, 0.12);
}

.box.auth-page .captcha-row .captcha-img-wrap,
.client-auth-overlay .captcha-row .captcha-img-wrap {
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.box.auth-page .captcha-row .captcha-img-wrap:hover,
.client-auth-overlay .captcha-row .captcha-img-wrap:hover {
    border-color: rgba(0, 5, 255, 0.4);
    box-shadow: none;
}

.email-code-row {
    display: flex;
    gap: 10px;
}

.email-code-row .form-control {
    flex: 1;
}

.email-code-row .btn {
    white-space: nowrap;
    min-width: 120px;
}

.box.auth-page .auth-links,
.client-auth-overlay .auth-links {
    text-align: center;
    margin-top: 20px;
}

.box.auth-page .auth-links a,
.box.auth-page .auth-links a:link,
.box.auth-page .auth-links a:visited,
.client-auth-overlay .auth-links a,
.client-auth-overlay .auth-links a:link,
.client-auth-overlay .auth-links a:visited {
    color: #fe4401 !important;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.box.auth-page .auth-links a:hover,
.client-auth-overlay .auth-links a:hover {
    color: #ff6a2d !important;
    text-decoration: underline;
}

/* Alerts */
.alert-msg {
    padding: 12px 16px;
    border-radius: var(--cp-radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    display: none;
    border-width: 1px;
    border-style: solid;
}

body.client-portal .alert-msg.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

body.client-portal .alert-msg.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

.box.auth-page .auth-container .alert-msg.alert-error,
.client-auth-overlay .auth-container .alert-msg.alert-error {
    background: rgba(255, 50, 50, 0.15);
    border: 1px solid #c33;
    color: #f88;
}

.box.auth-page .auth-container .alert-msg.alert-success,
.client-auth-overlay .auth-container .alert-msg.alert-success {
    background: rgba(50, 200, 50, 0.15);
    border: 1px solid #3a3;
    color: #8f8;
}

/* ----- Filters & content panels ----- */
.material-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--cp-surface);
    border-radius: var(--cp-radius);
    border: 1px solid var(--cp-border);
    box-shadow: var(--cp-shadow-sm);
}

.material-filters__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

.material-filters__actions {
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto;
}

.material-filters .form-control {
    width: auto;
    min-width: 200px;
    height: 42px;
    font-size: 14px;
}

.material-filters .client-date-input {
    min-width: 160px;
    color-scheme: light;
}

.material-filters .btn {
    height: 42px;
    cursor: pointer;
}

/* Flatpickr: English calendar, match portal typography */
.flatpickr-calendar {
    font-family: var(--cp-font) !important;
    box-shadow: var(--cp-shadow-lg) !important;
    border: 1px solid var(--cp-border) !important;
    border-radius: var(--cp-radius-sm) !important;
}

.flatpickr-months .flatpickr-month {
    color: var(--cp-text) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month .numInputWrapper input {
    font-weight: 600 !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--cp-brand) !important;
    border-color: var(--cp-brand) !important;
}

/* ----- Cards ----- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px;
    margin-bottom: 28px;
}

.material-card {
    background: var(--cp-surface);
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius);
    overflow: hidden;
    transition: var(--cp-transition);
    box-shadow: var(--cp-shadow-sm);
}

.material-card:hover {
    border-color: var(--cp-border-strong);
    box-shadow: var(--cp-shadow-md);
    transform: translateY(-3px);
}

.card-thumb {
    width: 100%;
    height: 180px;
    background: linear-gradient(145deg, #f1f5f9 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 42px;
    position: relative;
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-thumb__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.card-thumb__icon svg {
    width: 52px;
    height: 52px;
}

.card-thumb__icon--video {
    color: #2563eb;
}

.card-thumb__icon--audio {
    color: #7c3aed;
}

.card-thumb__icon--image {
    color: #0d9488;
}

.card-thumb__icon--archive {
    color: #c2410c;
}

.card-body {
    padding: 18px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--cp-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-meta {
    font-size: 13px;
    color: var(--cp-text-muted);
    margin-bottom: 14px;
}

.card-meta span {
    margin-right: 14px;
}

.card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    font-size: 13px;
    padding: 6px 14px;
    border-radius: var(--cp-radius-sm);
    cursor: pointer;
    transition: var(--cp-transition);
}

.btn-copy {
    background: var(--cp-surface);
    border: 1px solid var(--cp-border-strong);
    color: var(--cp-text);
}

.btn-copy:hover {
    background: var(--cp-brand);
    border-color: var(--cp-brand);
    color: #fff;
}

.file-ext-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(254, 68, 1, 0.12);
    color: #c53a00;
}

/* ----- Tables ----- */
.client-table-wrap {
    background: var(--cp-surface);
    border-radius: var(--cp-radius);
    border: 1px solid var(--cp-border);
    box-shadow: var(--cp-shadow-sm);
    overflow: auto;
}

.client-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
}

.client-table thead th {
    background: #f8fafc;
    color: var(--cp-text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 18px;
    border-bottom: 1px solid var(--cp-border);
    text-align: left;
    white-space: nowrap;
}

.client-table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--cp-border);
    font-size: 14px;
    color: var(--cp-text);
    vertical-align: middle;
}

.client-table tbody tr:last-child td {
    border-bottom: none;
}

.client-table tbody tr:hover {
    background: #f8fafc;
}

.btn-delete {
    background: transparent;
    border: 1px solid #fecaca;
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--cp-radius-sm);
    cursor: pointer;
    transition: var(--cp-transition);
}

.btn-delete:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

/* ----- Pagination ----- */
.pagination-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    color: var(--cp-text-muted);
    font-size: 14px;
}

.pagination-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination-btns .btn {
    background: var(--cp-surface);
    border: 1px solid var(--cp-border);
    color: var(--cp-text);
    min-width: 40px;
    height: 40px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--cp-radius-sm);
    cursor: pointer;
    transition: var(--cp-transition);
}

.pagination-btns .btn:hover,
.pagination-btns .btn.active {
    background: var(--cp-brand);
    border-color: var(--cp-brand);
    color: #fff;
}

.pagination-btns .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ----- Profile (full width like Sample / history pages) ----- */
.profile-form .profile-save-actions {
    text-align: center;
    margin-top: 24px;
}

.profile-form {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 28px 32px;
    background: var(--cp-surface);
    border-radius: var(--cp-radius);
    border: 1px solid var(--cp-border);
    box-shadow: var(--cp-shadow-md);
    box-sizing: border-box;
}

.profile-form .form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 0;
}

.profile-form .form-row .form-group {
    flex: 1;
}

/* ----- Modal (viewport-centered; use appendTo(body) when opened if inside transformed ancestors) ----- */
.modal-overlay {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
    background: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 10050;
    padding: 20px;
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--cp-surface);
    border: 1px solid var(--cp-border);
    border-radius: var(--cp-radius);
    padding: 28px 32px;
    width: 440px;
    max-width: 100%;
    box-shadow: var(--cp-shadow-lg);
    box-sizing: border-box;
    margin: auto;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    flex-shrink: 0;
}

.modal-box__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.modal-box__header h3 {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--cp-text);
    letter-spacing: 0.02em;
}

.modal-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--cp-text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    margin: 0;
    border-radius: var(--cp-radius-sm);
    transition: var(--cp-transition);
}

.modal-close:hover {
    color: var(--cp-text);
    background: #f1f5f9;
}

/* ----- Empty state (no emoji — use .empty-state__visual) ----- */
.empty-state {
    text-align: center;
    padding: 72px 24px;
    color: var(--cp-text-muted);
    background: var(--cp-surface);
    border: 1px dashed var(--cp-border-strong);
    border-radius: var(--cp-radius);
}

.empty-state__visual {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='1.25'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z'/%3E%3C/svg%3E") center / 48px 48px no-repeat;
    opacity: 0.85;
}

.empty-state p {
    font-size: 16px;
    font-weight: 500;
    color: var(--cp-text-muted);
    margin: 0;
}

/* Legacy: hide old emoji icon if still present */
.empty-state .icon {
    display: none;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .material-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .material-filters__fields,
    .material-filters__actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-end;
    }

    .material-filters .form-control {
        width: 100%;
        min-width: 0;
    }

    .auth-container {
        padding: 28px 22px;
    }

    .profile-form {
        padding: 20px 18px;
    }

    .profile-form .form-row {
        flex-direction: column;
        gap: 0;
    }

    .client-table thead th,
    .client-table tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .client-main {
        padding: 20px 0 36px;
    }
}
