/* ═══════════════════════════════════════════
   Celly Portal — Design System
   Modern, clean, mobile-first
   ═══════════════════════════════════════════ */

/* ── CSS Custom Properties ──────────────── */
:root {
    /* Brand Colors */
    --navy:           #0B2545;
    --navy-light:     #134074;
    --celly-blue:     #1A76D1;
    --blue-hover:     #155FA8;
    --blue-light:     #E8F1FB;
    --blue-50:        #F0F7FF;

    /* Neutrals */
    --dark:           #1A1A2E;
    --text:           #374151;
    --text-secondary: #6B7280;
    --text-muted:     #9CA3AF;
    --border:         #E5E7EB;
    --border-light:   #F3F4F6;
    --bg:             #F5F7FA;
    --white:          #FFFFFF;

    /* Semantic */
    --success:        #059669;
    --success-bg:     #ECFDF5;
    --error:          #DC2626;
    --error-bg:       #FEF2F2;
    --warning:        #D97706;
    --warning-bg:     #FFFBEB;
    --info:           #2563EB;
    --info-bg:        #EFF6FF;

    /* Typography */
    --font-heading:   'Montserrat', system-ui, sans-serif;
    --font-body:      'Source Sans 3', system-ui, sans-serif;

    /* Spacing */
    --space-xs:       4px;
    --space-sm:       8px;
    --space-md:       16px;
    --space-lg:       24px;
    --space-xl:       32px;
    --space-2xl:      48px;

    /* Radii */
    --radius-sm:      6px;
    --radius-md:      8px;
    --radius-lg:      12px;
    --radius-xl:      16px;
    --radius-full:    9999px;

    /* Shadows */
    --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md:      0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg:      0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl:      0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Layout */
    --nav-height:     70px;
    --max-width:      1440px;
    --content-width:  1200px;

    /* Transitions */
    --ease:           cubic-bezier(0.4, 0, 0.2, 1);
    --duration:       200ms;
}


/* ── Reset & Base ───────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--dark);
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

a {
    color: var(--celly-blue);
    text-decoration: none;
    transition: color var(--duration) var(--ease);
}

a:hover {
    color: var(--blue-hover);
}

img { max-width: 100%; display: block; }


/* ── Auth Layout (Login, Reset, etc.) ───── */
.auth-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

.auth-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.auth-brand {
    display: none;
    flex: 1;
    background: var(--navy);
    position: relative;
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

@media (min-width: 1024px) {
    .auth-brand {
        display: flex;
    }
}

.auth-brand-inner {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: var(--space-2xl);
    max-width: 480px;
}

.auth-brand h1 {
    color: var(--white);
    font-size: 2rem;
    margin-bottom: var(--space-md);
    font-weight: 700;
}

.auth-brand p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.125rem;
    line-height: 1.7;
}

/* Geometric background pattern for brand panel */
.auth-brand::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(26, 118, 209, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(26, 118, 209, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(26, 118, 209, 0.05) 0%, transparent 60%);
}

.auth-brand::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-card {
    width: 100%;
    max-width: 440px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-2xl);
}

.auth-logo-mark {
    width: 40px;
    height: 40px;
    background: var(--navy);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.125rem;
}

.auth-logo-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--dark);
}

.auth-logo-text span {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.875rem;
    display: block;
    margin-top: -2px;
}

.auth-card h2 {
    margin-bottom: var(--space-xs);
}

.auth-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    font-size: 0.9375rem;
}


/* ── Top Navigation Bar ─────────────────── */
.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--navy);
    height: var(--nav-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.topnav-inner {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    gap: var(--space-lg);
}

.topnav-logo-img {
    height: 40px;
    width: auto;
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    object-fit: contain;
}

.topnav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.topnav-links {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex: 1;
    padding: 0 var(--space-sm);
}

.topnav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: all var(--duration) var(--ease);
}

.topnav-link:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.topnav-link.active {
    color: var(--white);
    background: rgba(26, 118, 209, 0.3);
}

.topnav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Nav Dropdown Menus ─────────────────── */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
}

.nav-dropdown-trigger .dropdown-chevron {
    transition: transform var(--duration) var(--ease);
    opacity: 0.6;
    margin-left: -2px;
}

.nav-dropdown.open .dropdown-chevron {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    min-width: 220px;
    padding: var(--space-xs) 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--duration) var(--ease);
    z-index: 200;
}

.nav-dropdown.open .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-md);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}

.nav-dropdown-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    flex-shrink: 0;
}

.nav-dropdown-item:hover {
    background: var(--blue-light);
    color: var(--celly-blue);
}

.nav-dropdown-item:hover svg {
    opacity: 1;
}

.nav-dropdown-item.active {
    color: var(--celly-blue);
    background: var(--blue-50);
}

.nav-dropdown-item.active svg {
    opacity: 1;
}

/* Mobile: dropdowns become accordion */
@media (max-width: 768px) {
    .nav-dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: rgba(255, 255, 255, 0.05);
        padding: 0;
        display: none;
        min-width: auto;
    }

    .nav-dropdown.open .nav-dropdown-menu {
        display: block;
    }

    .nav-dropdown-item {
        color: rgba(255, 255, 255, 0.7);
        padding: 10px var(--space-md) 10px 48px;
    }

    .nav-dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--white);
    }

    .nav-dropdown-item.active {
        color: var(--white);
        background: rgba(26, 118, 209, 0.3);
    }

    .nav-dropdown-item svg {
        opacity: 0.6;
    }
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
    margin-left: auto;
}

.topnav-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    cursor: pointer;
    position: relative;
}

.topnav-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: var(--celly-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.8125rem;
}

.topnav-user-name {
    display: none;
}

@media (min-width: 768px) {
    .topnav-user-name {
        display: block;
    }
}

/* User dropdown menu */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    min-width: 200px;
    padding: var(--space-xs) 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--duration) var(--ease);
    z-index: 200;
}

.user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: var(--space-md) var(--space-md) var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

.user-dropdown-header strong {
    display: block;
    font-size: 0.875rem;
    color: var(--dark);
}

.user-dropdown-header small {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.user-dropdown a,
.user-dropdown button {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    color: var(--text);
    font-size: 0.875rem;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    font-family: var(--font-body);
    text-align: left;
    transition: background var(--duration) var(--ease);
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--blue-light);
    color: var(--celly-blue);
}

.user-dropdown svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-xs) 0;
}

/* Mobile hamburger */
.topnav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: var(--space-sm);
    margin-left: -var(--space-sm);
}

.topnav-toggle svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    .topnav-toggle {
        display: flex;
    }

    .topnav-links {
        display: none;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--navy);
        flex-direction: column;
        padding: var(--space-md);
        gap: var(--space-xs);
        overflow-y: auto;
        z-index: 99;
    }

    .topnav-links.open {
        display: flex;
    }

    .topnav-link {
        padding: 12px var(--space-md);
        font-size: 1rem;
        border-radius: var(--radius-md);
    }

    .topnav {
        padding: 0 var(--space-md);
    }
}


/* ── Main Content Area ──────────────────── */
.main-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-lg);
    min-height: calc(100vh - var(--nav-height));
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.page-header h1 {
    font-size: 1.5rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb span {
    color: var(--text-muted);
}


/* ── Cards ──────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: var(--space-lg);
    transition: box-shadow var(--duration) var(--ease);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}


/* ── Forms ──────────────────────────────── */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
    font-family: var(--font-heading);
}

.form-input {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-size: 0.9375rem;
    font-family: var(--font-body);
    color: var(--dark);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--duration) var(--ease);
    outline: none;
}

.form-input:focus {
    border-color: var(--celly-blue);
    box-shadow: 0 0 0 3px rgba(26, 118, 209, 0.12);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.error {
    border-color: var(--error);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.form-error {
    font-size: 0.8125rem;
    color: var(--error);
    margin-top: var(--space-xs);
}

/* Password toggle wrapper */
.input-password-wrap {
    position: relative;
}

.input-password-wrap .form-input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transition: color var(--duration) var(--ease);
}

.password-toggle:hover {
    color: var(--text);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

/* OTP / Code input */
.code-input-group {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    margin: var(--space-lg) 0;
}

.code-input {
    width: 52px;
    height: 60px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    font-family: var(--font-heading);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--duration) var(--ease);
}

.code-input:focus {
    border-color: var(--celly-blue);
    box-shadow: 0 0 0 3px rgba(26, 118, 209, 0.12);
}


/* ── Buttons ────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 11px 24px;
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--celly-blue);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--blue-hover);
    color: var(--white);
}

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--blue-light);
    border-color: var(--celly-blue);
    color: var(--celly-blue);
}

.btn-ghost {
    background: transparent;
    color: var(--celly-blue);
    padding: 11px 16px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--blue-light);
}

.btn-danger {
    background: var(--error);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background: #B91C1C;
    color: var(--white);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
}


/* ── Flash / Alert Messages ─────────────── */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.9375rem;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    animation: alertIn 300ms var(--ease);
}

@keyframes alertIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(5, 150, 105, 0.15);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(217, 119, 6, 0.15);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(37, 99, 235, 0.15);
}


/* ── Dashboard Grid ─────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    transition: all var(--duration) var(--ease);
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.blue   { background: var(--blue-light); color: var(--celly-blue); }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.amber  { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red    { background: var(--error-bg); color: var(--error); }

.stat-content h4 {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

.stat-content .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    font-family: var(--font-heading);
    line-height: 1.2;
}

.stat-content .stat-note {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 2px;
}


/* ── Quick Actions Grid ─────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
}

.quick-action-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    text-decoration: none;
    color: var(--text);
    transition: all var(--duration) var(--ease);
    box-shadow: var(--shadow-sm);
}

.quick-action-link:hover {
    border-color: var(--celly-blue);
    background: var(--blue-50);
    color: var(--celly-blue);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.quick-action-link svg {
    width: 22px;
    height: 22px;
    opacity: 0.7;
    flex-shrink: 0;
}

.quick-action-link:hover svg {
    opacity: 1;
}

.quick-action-link span {
    font-weight: 600;
    font-size: 0.9375rem;
    font-family: var(--font-heading);
}


/* ── Placeholder page styling ───────────── */
.placeholder-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    min-height: 50vh;
}

.placeholder-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xl);
    background: var(--blue-light);
    color: var(--celly-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.placeholder-icon svg {
    width: 36px;
    height: 36px;
}

.placeholder-page h2 {
    margin-bottom: var(--space-sm);
}

.placeholder-page p {
    color: var(--text-secondary);
    max-width: 400px;
}


/* ── Session Timer ──────────────────────── */
.session-timer {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}


/* ── Utilities ──────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.875rem; }
.text-xs     { font-size: 0.8125rem; }
.mt-sm       { margin-top: var(--space-sm); }
.mt-md       { margin-top: var(--space-md); }
.mt-lg       { margin-top: var(--space-lg); }
.mb-md       { margin-bottom: var(--space-md); }
.mb-lg       { margin-bottom: var(--space-lg); }
.flex        { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm      { gap: var(--space-sm); }
.gap-md      { gap: var(--space-md); }
.hidden      { display: none !important; }
.sr-only     { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }


/* ── Password Strength Meter ────────────── */
.password-strength {
    display: flex;
    gap: 4px;
    margin-top: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.password-strength-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    transition: background 300ms var(--ease);
}

.password-strength-bar.active.weak    { background: var(--error); }
.password-strength-bar.active.fair    { background: var(--warning); }
.password-strength-bar.active.good    { background: #34D399; }
.password-strength-bar.active.strong  { background: var(--success); }

.password-strength-text {
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 300ms var(--ease);
}


/* ── Footer ─────────────────────────────── */
.auth-footer {
    text-align: center;
    margin-top: var(--space-2xl);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.form-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-md);
    font-size: 0.875rem;
}

.form-links a {
    font-weight: 500;
}


/* ── Loading spinner ────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

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

.btn .spinner {
    width: 18px;
    height: 18px;
}


/* ── Data Tables ────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.data-table thead {
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

.data-table th {
    padding: 12px var(--space-md);
    text-align: left;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table td {
    padding: 12px var(--space-md);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--duration) var(--ease);
}

.data-table tbody tr:hover {
    background: var(--blue-50);
}

.data-table tbody tr.row-inactive {
    opacity: 0.55;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.user-cell-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--navy);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    font-family: var(--font-heading);
    flex-shrink: 0;
}


/* ── Badges ─────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.6875rem;
    font-weight: 600;
    font-family: var(--font-heading);
    border-radius: var(--radius-full);
    background: var(--border-light);
    color: var(--text-secondary);
    white-space: nowrap;
    line-height: 1.6;
}

.badge-blue {
    background: var(--blue-light);
    color: var(--celly-blue);
}

.badge-green {
    background: var(--success-bg);
    color: var(--success);
}

.badge-red {
    background: var(--error-bg);
    color: var(--error);
}


/* ── Status Dots ────────────────────────── */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-active  { background: var(--success); }
.status-inactive { background: var(--text-muted); }
.status-locked  { background: var(--error); }


/* ── Form Grid (2-column layout) ────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-light);
}

.required {
    color: var(--error);
}


/* ── Role Checkboxes ────────────────────── */
.role-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-sm);
}

.role-checkbox {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.role-checkbox:hover {
    border-color: var(--celly-blue);
    background: var(--blue-50);
}

.role-checkbox input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--celly-blue);
    flex-shrink: 0;
}

.role-checkbox input[type="checkbox"]:checked + .role-checkbox-content strong {
    color: var(--celly-blue);
}

.role-checkbox-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.role-checkbox-content strong {
    font-size: 0.875rem;
    color: var(--dark);
    font-family: var(--font-heading);
}

.role-checkbox-content span {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}


/* ── Toggle Switches ────────────────────── */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
}

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

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    transition: background var(--duration) var(--ease);
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration) var(--ease);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--celly-blue);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

.toggle-label strong {
    font-size: 0.875rem;
    font-family: var(--font-heading);
}


/* ── Account Actions ────────────────────── */
.account-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}


/* ── Filter Bar ─────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.form-input-sm {
    padding: 6px 10px;
    font-size: 0.8125rem;
    height: auto;
}


/* ── Warning / Overdue Rows ─────────────── */
.data-table tbody tr.row-warning {
    background: #FFF7ED;
}

.data-table tbody tr.row-warning:hover {
    background: #FFEDD5;
}

.text-error { color: var(--error) !important; }
.text-warning { color: #D97706 !important; }
.text-center { text-align: center; }

.badge-amber {
    background: #FEF3C7;
    color: #92400E;
}


/* ── Toggle Inline (checkbox + label) ───── */
.toggle-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
    white-space: nowrap;
}

.toggle-inline input {
    accent-color: var(--celly-blue);
}


/* ── Admin Hub Links ────────────────────── */
.admin-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

@media (min-width: 768px) {
    .admin-sections {
        grid-template-columns: 1fr 1fr;
    }
}

.admin-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 12px var(--space-md);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--dark);
    transition: background var(--duration) var(--ease);
}

.admin-link:hover {
    background: var(--blue-50);
}

.admin-link-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--blue-light);
    color: var(--celly-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-link-icon svg {
    width: 18px;
    height: 18px;
}

.admin-link div strong {
    display: block;
    font-size: 0.875rem;
    font-family: var(--font-heading);
}

.admin-link div span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-md);
}


/* ── Patient Styles ─────────────────────── */
.patient-link {
    color: var(--dark);
    text-decoration: none;
}

.patient-link:hover {
    color: var(--celly-blue);
}

.day-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-light);
}

.day-dot.active {
    background: var(--celly-blue);
}


/* ── Detail View ────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.detail-rows {
    display: flex;
    flex-direction: column;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.detail-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}


/* ── Schedule Grid ──────────────────────── */
.schedule-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.schedule-day {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg);
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.schedule-day.active {
    background: var(--blue-light);
    border-color: var(--celly-blue);
    color: var(--celly-blue);
}


/* ── Schedule Checkboxes (form) ─────────── */
.schedule-checkboxes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.schedule-checkbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.schedule-checkbox input {
    accent-color: var(--celly-blue);
    width: 20px;
    height: 20px;
}

.schedule-checkbox span {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
    color: var(--text-muted);
}

.schedule-checkbox input:checked + span {
    color: var(--celly-blue);
}


/* ── Form Grid (two column forms) ───────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    align-items: start;
}

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
}


/* ── Badge variants ─────────────────────── */
.badge-blue {
    background: var(--blue-light);
    color: var(--celly-blue);
}


/* ── Assignment Stats Bar ───────────────── */
.assign-stats {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.assign-stat {
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.assign-stat.warn { border-color: #F59E0B; background: #FFFBEB; }

.assign-stat-val {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--dark);
}

.assign-stat-lbl {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* ── Assignment Controls ────────────────── */
.assign-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.group-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.assign-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ── Assignment Groups ──────────────────── */
.assign-group {
    margin-bottom: var(--space-lg);
}

.assign-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-md);
    background: var(--navy);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.assign-group-header h3 {
    margin: 0;
    font-size: 0.9375rem;
    color: white;
}

.assign-group-header .badge {
    background: rgba(255,255,255,0.2);
    color: white;
}

.assign-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: var(--white);
}

.assign-table {
    font-size: 0.8125rem;
    margin: 0;
    border: none;
}

.assign-table th {
    font-size: 0.6875rem;
    padding: 8px 6px;
    white-space: nowrap;
}

.assign-table td {
    padding: 6px;
    vertical-align: top;
}

.text-xs { font-size: 0.75rem; }
.block { display: block; }

.data-table tbody tr.row-locked {
    background: #F0F9FF;
}


/* ── Reassign Sticky Bar ────────────────── */
.reassign-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    background: var(--navy);
    color: white;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
}


/* ── Action Menu (3-dot) ────────────────── */
.action-cell {
    position: relative;
}

.action-menu {
    position: relative;
    display: inline-block;
}

.action-trigger {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1;
    padding: 4px 8px;
}

.action-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 100;
    min-width: 160px;
    overflow: hidden;
}

.action-dropdown.open { display: block; }

.action-item {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.8125rem;
    cursor: pointer;
    color: var(--dark);
}

.action-item:hover { background: var(--blue-50, #F0F7FF); }
.action-danger { color: var(--error); }
.action-danger:hover { background: #FEF2F2; }


/* ── Dashboard Stat Cards ───────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    gap: var(--space-md);
    align-items: flex-start;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.amber { background: #FFFBEB; color: #D97706; }
.stat-icon.blue { background: var(--blue-light); color: var(--celly-blue); }

.stat-content h4 {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--dark);
    line-height: 1.2;
}

.stat-note {
    font-size: 0.75rem;
    color: var(--text-muted);
}


/* ── Quick Action Links ─────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}

.quick-action-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.875rem;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.quick-action-link:hover {
    border-color: var(--celly-blue);
    box-shadow: 0 2px 8px rgba(26,118,209,0.1);
}

.quick-action-link svg {
    width: 20px;
    height: 20px;
    color: var(--celly-blue);
}


/* ── Badge Variants ─────────────────────── */
.badge-amber { background: #FFFBEB; color: #D97706; }
.badge-green { background: #ECFDF5; color: #059669; }


/* ── Incident Reason Block ──────────────── */
.incident-reason {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--dark);
}


/* ── QA Criterion Row ───────────────────── */
.qa-criterion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    gap: var(--space-md);
}

.qa-criterion:last-child { border-bottom: none; }

.qa-criterion-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
}

.qa-code {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--celly-blue);
    background: var(--blue-light);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.qa-radios {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.qa-radio {
    cursor: pointer;
}

.qa-radio input { display: none; }

.qa-radio-label {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    border: 2px solid var(--border-light);
    background: var(--white);
    color: var(--text-muted);
    transition: all var(--duration) var(--ease);
}

.qa-radio input:checked + .qa-radio-label {
    border-color: var(--celly-blue);
    background: var(--blue-light);
    color: var(--celly-blue);
}

.qa-radio input:checked + .qa-radio-label.pass {
    border-color: #059669;
    background: #ECFDF5;
    color: #059669;
}

.qa-radio input:checked + .qa-radio-label.fail {
    border-color: #DC2626;
    background: #FEF2F2;
    color: #DC2626;
}


/* ── Percentage Bar ─────────────────────── */
.pct-bar {
    width: 80px;
    height: 8px;
    background: #E5E7EB;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.pct-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.pct-good { background: #059669; }
.pct-warn { background: #D97706; }
.pct-bad { background: #DC2626; }


/* ── Pay Bar (Sticky) ───────────────────── */
.pay-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    background: var(--navy);
    color: white;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
}

.text-right { text-align: right; }


/* ── Filter Grid (Treatment Filter) ────── */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-sm) var(--space-md);
}


/* ── Export Buttons ───────────────────── */
.export-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}
.export-buttons .btn svg { vertical-align: -2px; margin-right: 4px; }
.page-header-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-wrap: wrap;
}


/* ── Tab Bar ──────────────────────────── */
.tab-bar {
    display: flex;
    overflow-x: auto;
    border-bottom: 2px solid var(--border);
    gap: 0;
}
.tab-item {
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    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(--celly-blue);
    border-bottom-color: var(--celly-blue);
    font-weight: 600;
}

/* ── Resource Items ───────────────────── */
.resource-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.resource-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-light);
    border-radius: 8px;
    color: var(--celly-blue);
}
.resource-content { flex: 1; min-width: 0; }
.resource-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
    text-decoration: none;
}
a.resource-title:hover { color: var(--celly-blue); }


/* ── Invoice Create Layout ────────────── */
.invoice-create-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}
@media (max-width: 768px) {
    .invoice-create-layout { grid-template-columns: 1fr; }
}
