/* Nexrypt Dashboard Styles */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #a855f7;
    --accent: #22d3ee;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(148, 163, 184, 0.1);
    --nav-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Rich background gradient */
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
        radial-gradient(circle at bottom left, rgba(168, 85, 247, 0.15), transparent 40%),
        #0f172a;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-input);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Navbar */
.navbar {
    height: var(--nav-height);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transition: padding 0.3s ease;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.badge {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 24px;
}

.user-info-nav {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.user-info-nav strong {
    color: var(--text-main);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Layout */
.main-container {
    padding-top: calc(var(--nav-height) + 30px);
    padding-left: 40px;
    padding-right: 40px;
    padding-bottom: 40px;
    max-width: 1600px;
    margin: 0 auto;
    flex: 1;
    /* Pushes footer down */
    width: 100%;
    transition: padding 0.3s ease;
    /* Ensure footer stays at bottom */
    display: flex;
    flex-direction: column;
}

/* Master Control Bar */
.master-control-bar {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px 30px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.control-header h2 {
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.control-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn-master-large {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 10px 24px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.btn-master-large:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.02);
}

.master-icon {
    font-size: 1.5rem;
    background: rgba(16, 185, 129, 0.2);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-master-large .master-info {
    text-align: left;
}

.btn-master-large h3 {
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 600;
}

.btn-master-large span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stat-icon {
    min-width: 50px;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
}

.stat-icon.icon-blue {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.stat-icon.icon-purple {
    background: rgba(168, 85, 247, 0.1);
    color: var(--secondary);
}

.stat-icon.icon-cyan {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent);
}

.stat-info h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
}

.stat-info span {
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 700;
}

.success-text {
    color: var(--success) !important;
}

/* Quick Actions Row */
.quick-actions-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.action-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.action-card:hover {
    transform: translateY(-6px) scale(1.02);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.3);
    cursor: pointer;
}

.action-card:active {
    transform: translateY(-2px) scale(1);
}

.action-icon {
    min-width: 48px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: rgba(255, 255, 255, 0.05);
}

.action-icon.icon-blue {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.action-icon.icon-purple {
    background: rgba(168, 85, 247, 0.1);
    color: var(--secondary);
}

.action-icon.icon-red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.action-icon.icon-cyan {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent);
}

.action-icon.icon-green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.action-icon.icon-orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.action-info h4 {
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.action-info span {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 30px;
    align-items: start;
}

/* Sidebar */
.sidebar {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    height: calc(100vh - var(--nav-height) - 200px);
    min-height: 500px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

.status-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Device Cards */
.device-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.device-divider-full {
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
    margin: 25px 0 40px 0;
    opacity: 0.9;
    border-radius: 2px;
}

.device-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.device-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    cursor: pointer;
}

.device-card.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.device-card.active::before {
    opacity: 1;
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.device-name {
    font-weight: 600;
    font-size: 1rem;
}

.device-status {
    font-size: 1.2rem;
}

.device-status.online {
    color: var(--success);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.device-status.offline {
    color: var(--text-muted);
}

.device-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 16px;
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 8px;
    padding: 10px 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-action:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.btn-action:active {
    transform: translateY(-1px) scale(1.02);
}

.btn-action.danger:hover {
    background: var(--danger);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
}

.btn-action.success:hover {
    background: var(--success);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.btn-action.pulsing {
    animation: btn-pulse-success 2s infinite;
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    color: white !important;
}

@keyframes btn-pulse-success {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
        background: rgba(16, 185, 129, 0.15);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
        background: rgba(16, 185, 129, 0.3);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
        background: rgba(16, 185, 129, 0.15);
    }
}

/* Service Start/Stop Button - Enhanced Hover */
.btn-action[onclick*="SERVICE"] {
    font-weight: 600;
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-action[onclick*="SERVICE"]:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 12px 28px rgba(16, 185, 129, 0.5);
    filter: brightness(1.1);
}

.btn-action[onclick*="SERVICE_STOP"]:hover {
    box-shadow: 0 12px 28px rgba(239, 68, 68, 0.5);
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.map-container {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px;
    height: 500px;
    min-height: 300px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 14px;
    background: var(--bg-dark);
}

.device-card.termination-req {
    border: 2px solid var(--danger);
    background: rgba(239, 68, 68, 0.05);
    animation: borderPulse 2s infinite;
}

@keyframes borderPulse {
    0% {
        border-color: var(--danger);
    }

    50% {
        border-color: #fecaca;
    }

    100% {
        border-color: var(--danger);
    }
}

.termination-badge {
    background: var(--danger);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.termination-text {
    line-height: 1.4;
}

/* Lock Badge Styling */
.lock-badge {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(99, 102, 241, 0.2));
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeInLock 0.5s ease-out;
}

@keyframes fadeInLock {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lock-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 8px var(--accent));
}

.lock-details {
    display: flex;
    flex-direction: column;
}

.lock-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.unlock-code {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'Monaco', 'Consolas', monospace;
    letter-spacing: 1px;
}

.termination-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-approve {
    background: white;
    color: var(--danger);
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}

.btn-reject {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}

.btn-approve:hover {
    background: #fecaca;
    transform: scale(1.05);
}

.btn-reject:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

/* Gallery */
.gallery-section {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
}

.gallery-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.gallery-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.count-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.gallery-item {
    aspect-ratio: 9/16;
    background: var(--bg-dark);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease;
    cursor: zoom-in;
}

.gallery-item:hover {
    transform: scale(1.03);
    border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item .timestamp {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    padding: 16px 12px 10px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Footer */
.dashboard-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--glass-border);
    padding: 24px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

/* Message Toasts */
.message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 30px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    font-weight: 500;
    display: none;
    animation: slideUpToast 0.3s ease-out;
}

@keyframes slideUpToast {
    from {
        transform: translate(-50%, 20px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.message.success {
    border-color: var(--success);
    color: var(--success);
}

.message.error {
    border-color: var(--danger);
    color: var(--danger);
}

/* Legal & Support Pages */
.legal-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px;
    margin-top: 20px;
    line-height: 1.6;
    /* Push footer down */
    width: 100%;
    flex: 1;
}

.legal-container h1 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.legal-container h2 {
    color: var(--text-main);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.legal-container p {
    color: var(--text-muted);
    margin-bottom: 15px;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover {
    text-decoration: underline;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-main);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-submit {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-submit:hover {
    background: var(--primary-hover);
}

/* -------------------------------------------
 * AUTH PAGES (Login & Register)
 * ------------------------------------------- */
.auth-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent 50%),
        radial-gradient(circle at bottom left, rgba(168, 85, 247, 0.1), transparent 50%),
        var(--bg-dark);
}

.login-card {
    width: 100%;
    max-width: 400px;
    /* Force constraint */
    margin: auto;
    /* Fallback centering */
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: authFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.3));
}

.auth-logo h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.auth-logo .tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 400;
}

.auth-notice {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 24px;
    text-align: center;
}

.auth-notice p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.auth-form .form-group {
    margin-bottom: 24px;
}

.auth-form .form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-form .form-control {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 14px 16px;
    font-size: 1rem;
    width: 100%;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.auth-form .form-control:focus {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.auth-form .btn-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.auth-form .btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
    filter: brightness(1.1);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.auth-footer a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.auth-message {
    position: static;
    transform: none;
    margin-bottom: 12px;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
    padding: 0;
    border-radius: 0;
    display: none;
    font-weight: 500;
}

.auth-message.success {
    display: block;
    background: none;
    color: var(--success);
    border: none;
}

.auth-message.error {
    display: block;
    background: none;
    color: var(--danger);
    border: none;
}

/* -------------------------------------------
 * RESPONSIVE DESIGN
 * ------------------------------------------- */

/* Tablets & Small Laptops (1024px) */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        /* Stack sidebar and main content */
    }

    .sidebar {
        height: auto;
        min-height: 0;
        max-height: 400px;
        /* Limit height of device list */
        margin-bottom: 20px;
    }

    .stats-row,
    .quick-actions-row {
        gap: 15px;
        grid-template-columns: repeat(2, 1fr);
        /* 2x2 grid on tablets */
    }

    .map-container {
        height: 400px;
        /* Slightly shorter map */
    }
}

/* Mobile Devices (768px) */
@media (max-width: 768px) {
    :root {
        --nav-height: 60px;
    }

    /* Navbar */
    .navbar {
        padding: 0 12px;
        /* no overflow:hidden — it blocks touch scroll events */
    }

    .nav-brand h1 {
        font-size: 0.85rem;
    }

    .nav-brand {
        flex-shrink: 0;
        /* logo never shrinks */
        gap: 6px;
    }

    /* We keep PRO badge hidden to save space for the logo */
    .nav-brand .badge {
        display: none;
    }

    .user-info-nav {
        display: none;
        /* Hide User Info on mobile */
    }

    .nav-menu {
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        gap: 8px;
        /* Explicit max-width leaves room for the logo (~130px) + padding (24px) */
        max-width: calc(100vw - 155px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* smooth iOS scroll */
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE */
        padding-right: 8px;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
        /* WebKit */
    }

    /* keep items in a single row, non-shrinkable */
    .subscription-status-nav {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    /* ---- ALL 3 ITEMS: small, neat, with clear gaps ---- */
    .subscription-badge,
    .subscription-badge.trial,
    .subscription-badge.expired {
        padding: 3px 7px;
        font-size: 0.62rem;
        border-radius: 5px;
        gap: 3px;
        white-space: nowrap;
        flex-shrink: 0;
        line-height: 1.4;
    }

    .subscription-badge-icon {
        font-size: 0.65rem;
    }

    .btn-upgrade-nav {
        padding: 3px 7px;
        font-size: 0.57rem;
        /* Slightly smaller than badge to visually match */
        font-weight: 400;
        /* Override desktop font-weight:600 — that was making it look bigger */
        border-radius: 5px;
        gap: 3px;
        white-space: nowrap;
        flex-shrink: 0;
        line-height: 1.4;
    }

    .btn-logout {
        padding: 3px 7px;
        font-size: 0.62rem;
        border-radius: 5px;
        gap: 3px;
        white-space: nowrap;
        flex-shrink: 0;
        line-height: 1.4;
    }

    .btn-logout svg {
        width: 11px;
        height: 11px;
    }

    /* Layout */
    .main-container {
        padding: calc(var(--nav-height) + 16px) 16px 0;
        /* Remove bottom padding */
        width: 100%;
        overflow-x: hidden;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .legal-container {
        padding: 20px;
        margin-top: 10px;
    }

    /* Stats & Quick Actions */
    .master-control-bar {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 16px;
    }

    .btn-master-large {
        width: 100%;
        justify-content: center;
    }

    /* Stats - Force Horizontal */
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    /* Quick Actions - Stacked */
    .quick-actions-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 12px;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 8px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 1.2rem;
        margin: 0 auto;
    }

    .stat-info h4 {
        font-size: 0.75rem;
        white-space: normal;
        /* Allow wrapping if needed */
        line-height: 1.2;
    }

    .stat-info span {
        font-size: 1rem;
    }

    .action-card {
        padding: 16px;
    }

    /* Sidebar - Fix min-width issue */
    .sidebar {
        height: auto;
        min-height: auto;
        max-height: 300px;
        margin-bottom: 20px;
        width: 100%;
    }

    /* Map */
    .map-container {
        height: 350px;
        min-height: 250px;
    }

    /* Icons & Content */
    .device-actions {
        grid-template-columns: repeat(3, 1fr);
        /* Keep 3 buttons per row */
    }

    .btn-action {
        font-size: 0.75rem;
    }

    /* Footer - Full width at bottom (not fixed) */
    .dashboard-footer {
        width: 100%;
        padding: 24px 16px;
        flex-direction: column;
        gap: 16px;
        text-align: center;
        background: var(--bg-card);
        border-top: 1px solid var(--glass-border);
        border-radius: 0;
        margin-top: auto;
    }

    /* Reset spacing */
    .main-container {
        padding-bottom: 40px !important;
        flex: 1;
    }

    .footer-links {
        flex-direction: column;
        gap: 12px;
    }
}

/* Small Phones (480px) */
@media (max-width: 480px) {
    .device-actions {
        grid-template-columns: repeat(2, 1fr);
        /* 2 buttons per row on very small screens */
    }

    /* Stats remain 3 columns but more compact */
    .stats-row {
        gap: 6px;
    }

    .stat-card {
        padding: 8px;
    }

    .stat-info h4 {
        font-size: 0.65rem;
        /* Small but readable */
        display: block;
        /* Ensure visibility */
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
        font-size: 1rem;
        margin-bottom: 4px;
    }

    .nav-menu {
        gap: 10px;
        /* Still clear separation on smallest screens */
    }

    .nav-brand h1 {
        font-size: 0.85rem;
        /* Smallest neat logo */
    }

    .btn-logout,
    .btn-upgrade-nav,
    .subscription-badge {
        padding: 3px 6px;
        /* Absolute smallest neat padding */
        font-size: 0.65rem;
        /* Minimized text */
    }
}

/* Custom Map Markers */
.custom-dot-marker {
    background: none !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: auto !important;
    overflow: visible !important;
}

.dot-inner {
    width: 14px;
    height: 14px;
    background: #3b82f6;
    /* Blue for Stolen Device */
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.8), 0 0 5px rgba(255, 255, 255, 0.5);
    position: relative;
    z-index: 5;
    flex-shrink: 0;
}

.pin-icon {
    width: 38px;
    height: 38px;
    position: relative;
    z-index: 5;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.8));
    animation: pin-float 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes pin-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.dot-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: rgba(59, 130, 246, 0.4);
    border-radius: 50%;
    animation: pulse-ring 2s infinite;
    z-index: 1;
    pointer-events: none;
}

.dot-label {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: white;
    padding: 3px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

@keyframes pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Tracker (You) specific color - GREEN */
.tracker-dot .dot-inner {
    background: #10b981 !important;
    /* Force Green */
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.8), 0 0 5px rgba(255, 255, 255, 0.5);
}

.tracker-dot .dot-pulse {
    background: rgba(16, 185, 129, 0.5);
}

.tracker-dot .dot-label {
    border-color: var(--success);
}

/* --- USSD Terminal Redesign (Premium & Robust) --- */
#ussdTerminalSection.ussd-terminal-section {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98)) !important;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 24px;
    padding: 28px;
    margin-bottom: 35px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    position: relative;
    overflow: hidden;
    color: var(--text-main) !important;
}

#ussdTerminalSection .ussd-header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#ussdTerminalSection .ussd-status-led {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

#ussdTerminalSection .led-dot {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent);
    animation: led-pulse 2s infinite;
}

@keyframes led-pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

#ussdTerminalSection .ussd-console {
    background: #010409 !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    height: 260px;
    padding: 20px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace !important;
    font-size: 0.85rem;
    overflow-y: auto;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: inset 0 4px 30px rgba(0, 0, 0, 0.8);
    position: relative;
}

/* Scanline Effect */
#ussdTerminalSection .ussd-console::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
    opacity: 0.3;
}

#ussdTerminalSection .ussd-log {
    color: #4ade80 !important;
    /* Brighter Emerald */
    line-height: 1.6;
    word-break: break-all;
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
    border-left: 3px solid rgba(74, 222, 128, 0.3);
    padding-left: 14px;
}

#ussdTerminalSection .ussd-log.device {
    color: var(--accent) !important;
    text-shadow: 0 0 8px rgba(34, 211, 238, 0.4);
    border-left-color: rgba(34, 211, 238, 0.3);
}

#ussdTerminalSection .ussd-log.system {
    color: var(--text-muted) !important;
    font-style: italic;
    border-left-color: transparent;
    text-shadow: none;
}

#ussdTerminalSection .ussd-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

#ussdTerminalSection .ussd-input-group {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

#ussdTerminalSection .ussd-input-group:focus-within {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8) !important;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

#ussdTerminalSection .ussd-field {
    flex: 1;
    background: transparent !important;
    border: none !important;
    padding: 12px 16px;
    color: #fff !important;
    font-size: 0.9rem;
    font-family: inherit;
}

#ussdTerminalSection .ussd-field::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#ussdTerminalSection .btn-ussd {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#ussdTerminalSection .btn-dial {
    background: linear-gradient(135deg, var(--primary), #818cf8) !important;
    color: white !important;
}

#ussdTerminalSection .btn-reply {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-main) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

#ussdTerminalSection .btn-ussd:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

@media (max-width: 900px) {
    #ussdTerminalSection .ussd-controls {
        grid-template-columns: 1fr;
    }
}

/* Subscription Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    max-width: 450px;
    width: 90%;
    overflow: hidden;
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
}

.modal-text {
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
}

.modal-price {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
    text-align: center;
}

.price-tag {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 4px;
}

.price-period {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
}

.modal-footer {
    padding: 20px 24px 24px;
    display: flex;
    gap: 12px;
}

.btn-modal-primary,
.btn-modal-secondary {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modal-primary {
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: white;
}

.btn-modal-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-modal-secondary {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-modal-secondary:hover {
    background: rgba(148, 163, 184, 0.2);
}

/* Subscription Status Navigation */
.subscription-status-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.subscription-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
}

.subscription-badge.trial {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
    color: var(--secondary);
}

.subscription-badge.expired {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.subscription-badge-icon {
    font-size: 14px;
}

.btn-upgrade-nav {
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-upgrade-nav:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}

.home-link-back {
    position: absolute;
    top: 20px;
    left: 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: var(--transition);
}

.home-link-back:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

/* Live Tracking Mode Styles (Pulsing isolated to specific indicators as requested) */
/* Base dot for live status */
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    margin-right: 6px;
    position: relative;
    vertical-align: middle;
}

/* Pulsing effect only for the dot */
.live-dot::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 400%;
    height: 400%;
    background-color: var(--success);
    border-radius: 50%;
    transform: translate(-37.5%, -37.5%) scale(0.25);
    opacity: 0.5;
    animation: live-dot-pulse 1.5s ease-out infinite;
}

@keyframes live-dot-pulse {
    0% {
        transform: translate(-37.5%, -37.5%) scale(0.25);
        opacity: 0.8;
    }

    100% {
        transform: translate(-37.5%, -37.5%) scale(1.2);
        opacity: 0;
    }
}

.live-ping {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--danger);
    animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {

    75%,
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.pulse-red {
    animation: iconPulseRed 1.5s infinite;
}

@keyframes iconPulseRed {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 0px var(--danger));
    }

    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 15px var(--danger));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0px var(--danger));
    }
}

.action-card.active-live {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

.action-card.active-live .action-info h4 {
    color: var(--primary);
}

.action-card.active-live .action-info span {
    color: var(--text-main);
}

.action-card.active-live:hover {
    background: rgba(99, 102, 241, 0.2);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.3);
    border-color: var(--primary);
}

.action-card.active-live:hover * {
    color: white !important;
}

.btn-remove-device {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.1);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-remove-device:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.device-header {
    margin-bottom: 12px !important;
}