/* Remotrol.com palette (dark, calm, premium) */
:root {
    --color-bg-primary: #0a0e1a;
    --color-bg-secondary: #0f1624;
    --color-bg-tertiary: #1a1f2e;
    --color-surface: rgba(26, 31, 46, 0.7);
    --color-primary: #3b82f6;
    --color-primary-dark: #2563eb;
    --color-primary-light: #60a5fa;
    --color-text-primary: #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-text-muted: #64748b;
    --color-border: rgba(148, 163, 184, 0.1);
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --primary: #3b82f6;
    --secondary: #0ea5e9;
    --accent: #22d3ee;
    --light: #f3f6fb;
    --dark: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --border-color: rgba(148, 163, 184, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --card-bg: rgba(26, 31, 46, 0.85);
    --card-hover-shadow: 0 16px 34px rgba(59, 130, 246, 0.15);
    --input-bg: rgba(15, 22, 36, 0.8);
    --input-border: rgba(59, 130, 246, 0.3);
    --input-focus: #60a5fa;
    --button-hover: #2563eb;
}


body {
    margin: 0;
    padding: 0;
    font-family: 'Manrope', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Poppins', sans-serif;
    background: var(--color-bg-primary);
    background-image: radial-gradient(ellipse at 20% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
                      radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Light theme base (data-theme) */
body[data-theme="light"] {
    --color-bg-primary: #f7f9fc;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #eef2f7;
    --color-surface: rgba(255, 255, 255, 0.9);
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-primary-light: #60a5fa;
    --color-text-primary: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #64748b;
    --color-border: rgba(15, 23, 42, 0.12);
    --gradient-primary: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
    --primary: #2563eb;
    --secondary: #06b6d4;
    --accent: #22d3ee;
    --light: #f8fafc;
    --dark: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --gradient: linear-gradient(135deg, #2563eb, #06b6d4);
    --border-color: rgba(15, 23, 42, 0.12);
    --shadow-color: rgba(15, 23, 42, 0.12);
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-hover-shadow: 0 18px 40px rgba(37, 99, 235, 0.12);
    --input-bg: rgba(255, 255, 255, 0.95);
    --input-border: rgba(37, 99, 235, 0.25);
    --input-focus: #2563eb;
    --button-hover: #1d4ed8;
    color: var(--text-primary);
    background: radial-gradient(circle at 18% 18%, rgba(37,99,235,0.12), transparent 40%),
                radial-gradient(circle at 82% 10%, rgba(6,182,212,0.1), transparent 40%),
                linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

body[data-theme="light"] .nav-menu {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--color-border);
}

body[data-theme="light"] .card,
body[data-theme="light"] .login-form2,
body[data-theme="light"] .add-card {
    background: var(--card-bg);
    border: 1px solid var(--color-border);
    color: var(--text-primary);
}

body[data-theme="light"] .login-form2 {
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

body[data-theme="light"] .login-form2 input,
body[data-theme="light"] .code-login-form input,
body[data-theme="light"] .members-email-input,
body[data-theme="light"] .members-role-select {
    background-color: #ffffff;
    border-color: rgba(15, 23, 42, 0.12);
    color: #0f172a;
}

body[data-theme="light"] .login-form2 input::placeholder,
body[data-theme="light"] .code-login-form input::placeholder {
    color: #64748b;
}

body[data-theme="light"] .qr-scan-card,
body[data-theme="light"] .scan-card,
body[data-theme="light"] .qr-scan-modal,
body[data-theme="light"] .qr-scan-card {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(15, 23, 42, 0.12);
    color: var(--text-primary);
}

body[data-theme="light"] .rt-modal-layer > *,
body[data-theme="light"] .rt-modal {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(15, 23, 42, 0.12);
    color: var(--text-primary);
}

body[data-theme="light"] .card-members-content .members-row {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body[data-theme="light"] .nav-link,
body[data-theme="light"] .user-display,
body[data-theme="light"] .mainh1,
body[data-theme="light"] .section-subtitle {
    color: var(--text-primary);
}

body[data-theme="light"] .nav-link {
    color: var(--text-secondary);
}
body[data-theme="light"] .nav-link:hover {
    color: #0f172a;
    background: rgba(37, 99, 235, 0.12);
}
body[data-theme="light"] .nav-link.active {
    color: #ffffff;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.25);
}
body[data-theme="light"] .nav-links.active {
    background: rgba(255, 255, 255, 0.98);
    color: var(--text-primary);
}

body[data-theme="light"] .error {
    color: #e11d48;
}

.dark-mode {
    --primary: #60a5fa;
    --secondary: #22d3ee;
    --accent: #38bdf8;
    --light: #e2e8f0;
    --dark: #0f172a;
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;
    --gradient: linear-gradient(135deg, #60a5fa, #22d3ee);
    --border-color: rgba(255, 255, 255, 0.12);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --card-bg: rgba(30, 41, 59, 0.9);
    --card-hover-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    --input-bg: rgba(30, 41, 59, 0.85);
    --input-border: rgba(96, 165, 250, 0.35);
    --input-focus: #60a5fa;
    --button-hover: #3b82f6;
}

body.dark-mode {
    background: radial-gradient(circle at 18% 18%, rgba(79,141,246,0.16), transparent 36%),
                radial-gradient(circle at 82% 8%, rgba(37,194,213,0.14), transparent 36%),
                linear-gradient(180deg, #0d1527 0%, #0f1b31 50%, #0c1627 100%);
}

/* Navigation Bar */
.nav-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--color-surface);
    backdrop-filter: blur(18px);
    padding: 1rem 0;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    border-bottom: 1px solid var(--color-border);
}

.code-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    align-items: stretch;
}

.code-buttons button {
    margin: 0;
    flex: 1 1 calc(50% - 8px);
    min-width: 140px;
    max-width: 220px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    }

.code-buttons button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.code-buttons button:hover::after {
    transform: translateX(0);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* دکمه بستن منو - مخفی در حالت دسکتاپ */
.nav-links .close-menu {
    display: none;
}

.nav-link {
    padding: 0.65rem 1.2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    position: relative;
    transition: var(--transition);
    border-radius: 10px;
    background: transparent;
    border: 0;
    cursor: pointer;
    letter-spacing: 0.2px;
}

.nav-link::after {
    /* content: ''; */
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--gradient);
    transition: var(--transition);
}

.nav-link:hover {
    color: #fff;
    background: rgba(59, 130, 246, 0.12);
}

.nav-link:hover::after {
    width: 80%;
}

.nav-link.active {
    color: #0b172b;
    background: var(--gradient);
    box-shadow: 0 12px 28px rgba(79,141,246,0.32);
    border: 1px solid rgba(255,255,255,0.06);
}

.nav-link.active::after {
    width: 80%;
}

.language-toggle {
    font-size: 1.1rem !important;
    padding: 0.35rem 0.9rem !important;
    margin-left: 0.5rem;
    background: var(--gradient) !important;
    color: #0b172b !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(59,130,246,0.35);
    font-weight: 700;
}

.language-toggle:hover {
    background: var(--button-hover) !important;
    transform: translateY(-2px);
}

.user-display {
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 0.9rem;
    border: 1px solid rgba(255,255,255,0.08);
    overflow-wrap: anywhere;
}

.hamburger {
    display: none;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0.5rem;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    margin: 5px 0;
    transition: var(--transition);
}

@media (max-width: 768px) {
    .hamburger {
        display: block;
    }
    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        transform: translateX(100%);
        height: 100vh;
        width: 100%;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(12px);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: transform 0.5s ease;
        z-index: 1001;
        padding: 20px 0;
        overflow-y: auto;
    }
    
    /* پشتیبانی از RTL برای زبان فارسی */
    html[dir="rtl"] .nav-links {
        transform: translateX(-100%);
    }
    
    html[dir="rtl"] .nav-links.active {
        transform: translateX(0);
    }
    
    .nav-links.active {
        transform: translateX(0);
    }
    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 6px);
    }
    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }
    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -5px);
    }
    
    /* دکمه بستن منو در حالت موبایل */
    .nav-links .close-menu {
        display: flex;
        position: absolute;
        top: 20px;
        right: 20px;
        background: var(--primary);
        color: white;
        border: none;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        z-index: 2;
    }
    
    /* پشتیبانی از RTL برای دکمه بستن */
    html[dir="rtl"] .nav-links .close-menu {
        right: auto;
        left: 20px;
    }
    
    /* فاصله بیشتر بین آیتم‌های منو در موبایل */
    .nav-links .nav-link {
        margin: 8px 0;
        width: 75%;
        text-align: center;
        padding: 12px;
        font-size: 1.1rem;
    }
    
    /* استایل نمایش کاربر در موبایل */
    .nav-links .user-display {
        margin: 15px 0;
        text-align: center;
        padding: 10px;
        width: 75%;
        max-width: 280px;
    }
    
    /* دکمه زبان در موبایل */
    .nav-links .language-toggle {
        margin-top: 15px;
    }
}

/* Headers */
.mainh1 {
    text-align: center;
    margin: 2rem 0;
    color: var(--text-primary);
    font-size: clamp(1.9rem, 4.5vw, 2.7rem);
    margin-top: 120px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

/* Code Container */
.container-codes {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.codes-loader {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: var(--card-hover-shadow);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-secondary);
    min-height: 180px;
}

.codes-loader .spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(148, 163, 184, 0.4);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: codespin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes codespin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--card-hover-shadow);
    border: 1px solid rgba(255,255,255,0.06);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

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

.card h3 {
    color: var(--text-primary);
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.card p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.status-badge {
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.status-online {
    background: linear-gradient(135deg, #16a34a, #22c55e);
}

.status-offline {
    background: linear-gradient(135deg, #64748b, #94a3b8);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.last-seen {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.card button {
    padding: 0.75rem 1.15rem;
    border: none;
    border-radius: 10px;
    background: var(--gradient);
    color: #0b172b;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 12px 30px rgba(79,141,246,0.28);
}

.card button:hover {
    background: var(--button-hover);
    transform: translateY(-3px);
    box-shadow: 0 14px 30px rgba(47, 111, 222, 0.3);
}

/* Add Card */
.add-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: var(--transition);
    min-height: 200px;
    backdrop-filter: blur(18px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.add-card:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    transform: translateY(-5px);
    background-color: rgba(59, 130, 246, 0.08);
}

.rt-add-device-panel {
    max-width: 60%;
    justify-self: center;
    padding: 0 var(--rt-space-lg, 1.5rem);
}
.rt-add-device-panel .add-card {
    min-height: unset;
    /* width: 100%; */
    padding: 1.6rem 2rem;
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(14, 116, 144, 0.08));
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
    text-align: start;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}
.rt-add-device-panel .add-card:hover {
    transform: translateY(-3px);
    border-color: rgba(59, 130, 246, 0.45);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.24), rgba(14, 116, 144, 0.12));
}
.add-card-hero:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.7);
    outline-offset: 4px;
}
.dark-mode .rt-add-device-panel .add-card {
    border-color: rgba(96, 165, 250, 0.35);
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.18), rgba(34, 211, 238, 0.1));
}
.add-card-body {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.add-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--gradient);
    color: #0b172b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(59, 130, 246, 0.35);
}
.add-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.add-card-sub {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.2rem;
}
.add-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}
.add-card-actions .control-btn,
.add-card-actions .btn-secondary {
    margin: 0;
    padding: 0.7rem 1.1rem;
    min-width: 140px;
    width: auto;
}
@media (max-width: 768px) {
    .rt-add-device-panel .add-card {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 1.4rem 1.5rem;
    }
    .add-card-body {
        justify-content: center;
    }
    .add-card-actions {
        justify-content: center;
    }
}

/* QR Scan card + modal */
.scan-card {
    border: 2px dashed rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.05);
}
.scan-card:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
}
.qr-scan-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    z-index: 9999;
}
.qr-scan-modal.hidden {
    display: none;
}
.qr-scan-card {
    /* width: min(520px, 92vw); */
    background: var(--card-bg);
    border-radius: 18px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.qr-scan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.qr-scan-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.qr-video-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.2);
    background: #0b1221;
}
.qr-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.qr-frame {
    position: absolute;
    inset: 12%;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    pointer-events: none;
}
.qr-scan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.qr-scan-actions .control-btn,
.qr-scan-actions .btn-secondary {
    flex: 1 1 140px;
}
.qr-upload input {
    display: none;
}
.qr-scan-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Modals */
.login-form2 {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.18);
    z-index: 1000;
    width: 92vw;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    border: 1px solid rgba(15,23,42,0.08);
    backdrop-filter: blur(16px);
}

.login-form2 h3 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.login-form2 input {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    transition: var(--transition);
    background-color: var(--input-bg);
    color: var(--text-primary);
    box-sizing: border-box;
}
.login-form2 select,
.login-form2 textarea {
    width: 100%;
    box-sizing: border-box;
}

.login-form2 input:focus {
    border-color: var(--input-focus);
    outline: none;
    box-shadow: 0 0 0 3px rgba(184, 151, 61, 0.15);
}
.login-form2 .code-input {
    text-align: center;
    letter-spacing: 0.15rem;
    font-weight: 700;
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 2px solid var(--input-border);
}
.login-form2 .code-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}
.login-form2 .code-input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(79, 141, 246, 0.25);
}
.verify-timer {
    margin: -0.5rem 0 0.5rem 0;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
}
.verify-timer.hidden { display: none; }

.transfer-modal-card { max-width: 420px; margin: 0 auto; }
.transfer-warning { color: var(--text-secondary); margin: 0.5rem 0 1rem; }
.transfer-confirm-section { margin: 1rem 0; }
.transfer-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.transfer-tab { padding: 0.5rem 1rem; border-radius: 8px; border: 1px solid var(--border-color, #e2e8f0); background: var(--card-bg, #fff); color: var(--text-primary); cursor: pointer; }
.transfer-tab.active { background: var(--gradient, linear-gradient(135deg, #3b82f6, #60a5fa)); color: #0b172b; border-color: transparent; }
.transfer-panel { margin-top: 0.5rem; }
.transfer-panel input { margin-bottom: 0.5rem; }
.transfer-panel.hidden { display: none; }
.transfer-actions { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.transfer-actions .control-btn,
.transfer-actions .btn-danger { flex: 1; min-width: 120px; }
.notification-toggles { display: flex; flex-direction: column; gap: 0.75rem; margin: 1rem 0; }
.notification-toggles .toggle-row { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; color: var(--text-primary); }
.notification-toggles .toggle-row input[type="checkbox"] { width: 1.2rem; height: 1.2rem; }
.muted { color: var(--color-text-muted, var(--text-secondary)); font-size: 0.85rem; }

.login-form2 button {
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.8rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    box-sizing: border-box;
}

.control-btn {
    /* max-width: 160px; */
    background: var(--gradient);
    color: #0b172b;
    border: none;
    box-shadow: 0 12px 30px rgba(79,141,246,0.3);
}

.control-btn:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.35);
}

.btn-danger {
    background: #DC2626 !important;
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #B91C1C !important;
    transform: translateY(-2px);
}

/* Forgot Password Link */
.forgot-password-link {
    text-align: center;
    color: var(--primary);
    margin-top: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

.forgot-password-link:hover {
    color: var(--secondary);
}

/* Theme Toggle */
.toggle-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-direction: column;
}

.toggle-theme {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--gradient);
    border: none;
    cursor: pointer;
    color: #0b172b;
    font-size: 1.2rem;
    box-shadow: 0 10px 25px rgba(59,130,246,0.35);
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-theme:hover {
    transform: scale(1.1);
}

.toggle-language {
    background: var(--gradient) !important;
    font-size: 1rem !important;
}

.toggle-language:hover {
    background: var(--button-hover) !important;
}

/* Dark Mode */
.dark-mode {
    --primary: #60a5fa;
    --secondary: #22d3ee;
    --accent: #38bdf8;
    --light: #e2e8f0;
    --dark: #0f172a;
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;
    --gradient: linear-gradient(135deg, #60a5fa, #22d3ee);
    --border-color: rgba(255, 255, 255, 0.12);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --card-bg: rgba(30, 41, 59, 0.9);
    --card-hover-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    --input-bg: rgba(30, 41, 59, 0.85);
    --input-border: rgba(96, 165, 250, 0.35);
    --input-focus: #60a5fa;
    --button-hover: #3b82f6;
}

.dark-mode .nav-menu {
    background: rgba(8, 15, 30, 0.9);
}

.dark-mode .card,
.dark-mode .login-form2,
.dark-mode .add-card {
    background: var(--card-bg);
}

.dark-mode .card h3 {
    color: var(--text-primary);
}

.dark-mode .error {
    color: #FB7185;
}

/* تنظیم رنگ در حالت تاریک برای منوی موبایل */
.dark-mode .nav-links {
    /* background: rgba(15, 23, 42, 0.98); */
    color: var(--text-primary);
}

.dark-mode .nav-link {
    color: var(--text-primary);
}

.user-display {
    color: var(--text-primary);
    font-weight: 700;
}

/* Responsiveness */
@media (max-width: 768px) {
    .container-codes {
        grid-template-columns: 1fr;
        padding: 0 1.5rem;
    }
    
    .login-form2 {
        width: 85%;
        padding: 2rem;
    }
}

@media (max-width: 640px) {
    .nav-menu { padding: 0.6rem 0; }
    .nav-container { padding: 0 1rem; }
    .nav-logo { font-size: 1.25rem; }
    .nav-links .close-menu {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
        top: 14px;
        right: 14px;
    }
    html[dir="rtl"] .nav-links .close-menu {
        left: 14px;
        right: auto;
    }
    .nav-links .nav-link {
        width: 85%;
        padding: 10px;
        font-size: 1rem;
    }
    .nav-links .user-display {
        width: 85%;
        font-size: 0.85rem;
    }
    .mainh1 {
        margin-top: 90px;
        font-size: clamp(1.6rem, 7vw, 2.1rem);
    }
    .section-subtitle { font-size: 0.92rem; }
    .container-codes { padding: 0 1rem; gap: 1.25rem; }
    .card {
        padding: 1.25rem;
        border-radius: 14px;
        gap: 0.75rem;
    }
    .device-card {
        padding: 1.1rem;
        border-radius: 14px;
        gap: 10px;
    }
    .device-name { font-size: 1.05rem; }
    .device-code { font-size: 0.8rem; }
    .status-chip {
        font-size: 0.75rem;
        padding: 4px 10px;
    }
    .meta-row { font-size: 0.85rem; }
    .card-actions button {
        min-height: 40px;
        padding: 0.65rem 0.85rem;
        font-size: 0.88rem;
    }
    .login-form2 {
        width: 92vw;
        max-width: 360px;
        padding: 1.6rem;
    }
    .login-form2 h3 { font-size: 1.2rem; }
    .login-form2 input {
        width: 100%;
        padding: 0.8rem;
        font-size: 0.95rem;
    }
    .login-form2 button {
        padding: 0.8rem;
        font-size: 0.95rem;
    }
    .qr-scan-card {
        width: min(420px, 92vw);
        padding: 1.1rem;
        border-radius: 14px;
    }
    .qr-scan-desc { font-size: 0.9rem; }
    .qr-scan-actions {
        gap: 0.5rem;
    }
    .qr-scan-actions .control-btn,
    .qr-scan-actions .btn-secondary {
        flex: 1 1 100%;
        min-height: 40px;
    }
    .code-buttons button {
        min-width: 120px;
        min-height: 38px;
        font-size: 0.9rem;
    }
    .toggle-container {
        right: 14px;
        bottom: 14px;
        gap: 6px;
    }
    .toggle-theme {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0 0.9rem;
    }
    
    .login-form2 {
        padding: 1.35rem;
    }
    
    .code-buttons button {
        flex: 1 1 100%;
    }

    .mainh1 { margin-top: 78px; }
    .card { padding: 1.1rem; }
    .device-card { padding: 1rem; }
    .card-actions button { font-size: 0.84rem; }
    .login-form2 input { padding: 0.7rem; }
    .login-form2 button { padding: 0.75rem; }
    .qr-scan-card { padding: 1rem; }
}

.hidden {
    display: none !important;
}

.hidden-visually {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.error {
    color: #F43F5E;
    margin-top: 0.8rem;
    text-align: center;
    font-size: 0.9rem;
}

.copyright-bar {
    text-align: center;
    padding: 1rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Wide Stats */
.wide-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    padding: 0 1rem;
}

.stat.ww {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 20px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

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

.stat.ww h2 {
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Code Login Section */
.code-login-section {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px var(--shadow-color);
    border: 1px solid var(--border-color);
}

.code-login-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 600;
}

.code-login-form {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.code-login-form input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--text-primary);
}

.code-login-form input:focus {
    border-color: var(--input-focus);
    outline: none;
    box-shadow: 0 0 0 3px rgba(184, 151, 61, 0.15);
}

.code-login-form button {
    padding: 12px 20px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    font-weight: 500;
}

.code-login-form button:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
}

/* Steps for Forgot Password */
#emailStep, #codeStep {
    margin-bottom: 1rem;
}

.badge-new {
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7em;
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.2);
}

html[dir="rtl"] .badge-new {
    margin-right: 0;
    margin-left: 8px;
}

/* Remove old styles */
.subscription-badge.new-code {
    display: none;
}

.no-subscription {
    display: none;
}
/* Added enhancements */
.page-loader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.6);
    z-index: 999;
}
.page-loader.hidden { display: none; }
.loader-card {
    background: var(--card-bg);
    padding: 18px 28px;
    border-radius: 16px;
    box-shadow: var(--card-hover-shadow);
    text-align: center;
    min-width: 260px;
}
.loader-ring {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 12px auto;
    animation: spin 0.9s linear infinite;
}
.loader-title { font-weight: 700; color: var(--text-primary); }
.loader-sub { color: var(--text-secondary); font-size: 0.9rem; }

.device-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: var(--card-hover-shadow);
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.device-card:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.25);
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.card-titles { display: flex; flex-direction: column; gap: 4px; }
.device-name { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
.device-code { font-size: 0.9rem; color: var(--text-secondary); }
.status-chip { padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; }
.status-chip.status-online { background: rgba(16, 185, 129, 0.25); color: #34d399; }
.status-chip.status-offline { background: rgba(248, 113, 113, 0.2); color: #f87171; }
.plan-badge { font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 6px; font-weight: 600; background: var(--color-border); color: var(--color-text-secondary); }
.card-meta { display: flex; flex-direction: column; gap: 8px; }
.meta-row { display: flex; justify-content: space-between; font-size: 0.95rem; color: var(--text-secondary); }
.meta-label { font-weight: 600; color: var(--text-primary); }
.meta-expiry { color: var(--text-primary); font-weight: 600; }
.card-actions {
    display: flex;
    flex-flow: wrap;
    justify-content: center;
    gap: 5px;
}
.card-actions button {
    flex: 1 1 160px;
    min-height: 44px;
    padding: 0.55rem 0rem;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    transition: var(--transition);
    max-width: 49%;
}
.device-card .btn-secondary {
    background: var(--input-bg, rgba(255,255,255,0.05));
    color: var(--text-primary);
    box-shadow: none;
    border-color: var(--text-primary);
}
.device-card .btn-secondary:hover {
    background: rgba(255,255,255,0.12);
    transform: translateY(-1px);
}
.device-card .btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
    box-shadow: 0 10px 24px rgba(220,38,38,0.25);
}
.device-card .btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}
.device-card .control-btn {
    color: #0b172b;
}
.shared-devices-section { margin-bottom: 1.5rem; }
.section-subtitle {font-size: 1rem;color: var(--text-secondary);margin: 0.5rem 0 0.75rem;font-weight: 600;text-align: center;}
.device-card-shared .card-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.role-badge { font-size: 0.7rem; padding: 0.2rem 0.5rem; border-radius: 999px; font-weight: 700; text-transform: uppercase; }
.role-badge.role-viewer { background: rgba(56, 189, 248, 0.25); color: #38bdf8; }
.role-badge.role-admin { background: rgba(139, 92, 246, 0.25); color: #a78bfa; }
.card-members-content { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border-color); }
.card-members-content.hidden { display: none; }
.card-members-content .members-list { margin-bottom: 0.75rem; min-height: 2rem; }
.card-members-content .members-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.card-members-content .members-email { flex: 1 1 120px; }
.card-members-content .members-role { font-size: 0.75rem; text-transform: uppercase; }
.card-members-content .members-add { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.card-members-content .members-email-input { flex: 1 1 140px; min-width: 0; padding: 0.4rem 0.6rem; border-radius: 8px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--text-primary); }
.card-members-content .members-role-select { padding: 0.4rem 0.6rem; border-radius: 8px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--text-primary); }
.card-members-content .members-limits { color: var(--text-secondary); margin-top: 0.35rem; }
.card-members-content .small { font-size: 0.8rem; }
.card-members-content .members-remove-btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

.strength-meter { width: 100%; height: 6px; background: var(--input-bg); border-radius: 10px; overflow: hidden; margin-top: 6px; }
.strength-bar { height: 100%; width: 0; background: #ef4444; transition: width 0.2s ease, background 0.2s ease; }
.strength-bar[data-level="medium"] { background: #f59e0b; }
.strength-bar[data-level="strong"] { background: #22c55e; }
.strength-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; }
.pw-req { list-style: none; margin: 6px 0 10px 0; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; color: var(--text-secondary); }
.pw-req { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.pw-req li { display: flex; align-items: center; gap: 8px; }
.pw-req li::before { content: '○'; font-size: 0.75rem; color: var(--text-secondary); }
.pw-req li.met { color: var(--text-primary); font-weight: 600; }
.pw-req li.met::before { content: '✔'; color: #22c55e; }

.auth-checking #loginModal,
.auth-checking #registerModal,
.auth-checking #verifyModal,
.auth-checking #changePasswordModal,
.auth-checking #mainContent { display: none !important; }

@media (max-width: 768px) {
    .device-card { padding: 1.2rem; }
    .card-actions {/* flex-direction: column; */}
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes modal-pop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* New Structure Styles - Integration with UI Kit */
.rt-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.rt-top-bar {
    position: sticky;
    top: 0;
    z-index: var(--rt-z-sticky, 200);
}

.rt-main-content {
    flex: 1;
    padding-top: var(--rt-space-lg, 1.5rem);
}

.rt-modal-layer {
    position: fixed;
    inset: 0;
    z-index: var(--rt-z-modal-backdrop, 900);
    pointer-events: none;
    background: rgba(8, 15, 30, 0.42);
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}

.rt-modal-layer.modal-active {
    opacity: 1;
    pointer-events: auto;
}

.rt-modal-layer > * {
    pointer-events: auto;
}

.rt-modal-layer .rt-modal.hidden {
    display: none;
}

.rt-modal {
    animation: modal-pop 0.18s ease-out;
}

body.modal-open {
    overflow: hidden;
}

.rt-footer {
    margin-top: auto;
    padding: var(--rt-space-lg, 1.5rem) 0;
}

.rt-content-header {
    text-align: center;
    margin-bottom: var(--rt-space-xl, 2rem);
}

.rt-devices-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--rt-space-lg, 1.5rem);
}

.rt-devices-your {
    margin-top: var(--rt-space-xl, 2rem);
}
.qr-scan-card button{
    border-radius: 10px;
}
.qr-upload{
    text-align: center;
}
/* Responsive adjustments for new structure */
@media (max-width: 768px) {
    .rt-main-content {
        padding-top: var(--rt-space-md, 1rem);
    }
    
    .rt-devices-section {
        padding: 0 var(--rt-space-md, 1rem);
    }
}

/* RTL Support for new structure */
[dir="rtl"] .rt-content-header {
    text-align: right;
}

[dir="ltr"] .rt-content-header {
    text-align: left;
}
