:root {
    /* Premium Dark Mode Palette */
    --bg-color: #0f172a;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --surface-color: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.5);
    
    --secondary: #8b5cf6;
    
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --input-bg: rgba(30, 41, 59, 0.9);
    --input-border: rgba(255, 255, 255, 0.2);
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --nav-height: 70px;
    --header-height: 60px;
}

.hidden { display: none !important; }

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    line-height: 1.5;
}

.glass-panel {
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.app-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--surface-border);
    z-index: 100;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i { color: var(--primary); }

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(var(--nav-height) + 20px);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--surface-border);
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    gap: 4px;
    transition: 0.3s;
}

.nav-item.active { color: var(--primary); }
.nav-item i { font-size: 1.2rem; }

/* Squad Cards */
.squad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.squad-card {
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.squad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.squad-timer {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--primary);
}

.member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
}

/* Forms */
.form-group { margin-bottom: 15px; width: 100%; }
label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; }
input, select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: white;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

/* Custom File Upload */
.file-upload-wrapper {
    position: relative;
    width: 100%;
    margin-top: 5px;
}

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

.file-label {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed var(--surface-border);
    padding: 30px !important;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-muted) !important;
    text-align: center;
}

.file-label:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
    color: var(--text-main) !important;
}

.file-label i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.file-name-hint {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 5px;
}

.btn {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-outline { background: rgba(255,255,255,0.05); color: white; border: 1px solid rgba(255,255,255,0.1); }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* User Grid & Cards */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.user-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 18px;
    transition: all 0.3s ease;
    gap: 15px;
}

.user-card:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.user-info-main {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar-small {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
}

.user-details h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    border-radius: 6px;
    margin-top: 5px;
}

.role-admin { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.role-user { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.3); }

.user-actions-row {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: flex-end;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 15px;
}

/* Modals & Centering */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

#modal-container > div:not(.hidden) {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Scan Feedback Radar */
#modal-scan {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(59, 130, 246, 0.3);
    width: 320px;
    height: auto;
    min-height: 350px;
    border-radius: 40px;
    position: relative;
    overflow: hidden;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.radar-container {
    position: relative;
    width: 140px;
    height: 140px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radar-circle {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.radar-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--primary);
    border-radius: 50%;
    opacity: 0;
    animation: ripple 2s infinite linear;
}

.radar-ripple:nth-child(2) { animation-delay: 0.6s; }
.radar-ripple:nth-child(3) { animation-delay: 1.2s; }

@keyframes ripple {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(2.5); opacity: 0; }
}

#scan-feedback i {
    font-size: 4rem;
    color: white;
    text-shadow: 0 0 20px var(--primary);
    z-index: 3;
    animation: pulse 2s infinite;
}

#scan-text {
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: white;
}

.scan-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 25px;
    max-width: 220px;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Squad Monitoring Extras */
.squad-status-bar {
    display: flex;
    justify-content: space-around;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.status-item { display: flex; flex-direction: column; align-items: center; }
.status-item label { font-size: 0.6rem; text-transform: uppercase; margin-bottom: 2px; }
.status-item span { font-size: 1rem; font-weight: 700; color: var(--success); }

.squad-card.warning {
    border: 2px solid var(--danger);
    animation: blink-danger 1s infinite;
}

@keyframes blink-danger {
    0% { background: var(--surface-color); }
    50% { background: rgba(239, 68, 68, 0.2); }
    100% { background: var(--surface-color); }
}

/* List Items (Members/Devices) */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
}

.item-name { font-weight: 600; font-size: 1.1rem; }
.item-meta { font-size: 0.8rem; color: var(--text-muted); }

/* Views */
.view { display: none; animation: fadeIn 0.3s ease-out; }
.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.squad-select {
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 600;
    text-align: right;
    width: auto;
    max-width: 150px;
    cursor: pointer;
    outline: none;
}
.squad-select option { background: var(--bg-color); color: white; }

/* Scanner Styling */
.scanner-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
}

.scanner-video {
    width: 100%;
    height: auto;
    display: block;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-box {
    width: 70%;
    height: 60%;
    border: 2px solid var(--primary);
    border-radius: 10px;
    box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
    position: relative;
}

.scanner-laser {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    animation: laser-scan 2s infinite linear;
}

@keyframes laser-scan {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

.scanner-controls {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0 10px;
}