/* ===== Tapra Resident App - Modern UI with Light/Dark Theme ===== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;

    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-light: #ef4444;
    --danger-50: #fef2f2;

    --success: #16a34a;
    --success-light: #22c55e;
    --success-50: #f0fdf4;

    --warning: #d97706;
    --warning-light: #f59e0b;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --white: #ffffff;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.15);

    /* Theme Variables (Light default) */
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Dark Theme - Glassmorphism */
.dark-theme {
    --bg-primary: #0a0f1a;
    --bg-secondary: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-glass: rgba(30, 41, 59, 0.4);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.06);

    --white: #0f172a;
    --gray-50: #1e293b;
    --gray-100: #0f172a;
    --gray-200: rgba(255, 255, 255, 0.08);
    --gray-800: #f1f5f9;

    --glass-blur: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    font-family: var(--font);
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

.hidden {
    display: none !important;
}

/* ===== App Container ===== */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--white);
}

/* ===== Login Screen ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 0 0 50% 50% / 0 0 15% 15%;
}

.login-content {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 40px 24px;
}

.login-header {
    text-align: center;
    padding-top: 40px;
    margin-bottom: 40px;
}

.login-logo {
    margin-bottom: 20px;
}

.logo-shield {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.logo-shield svg {
    width: 44px;
    height: 44px;
    color: var(--white);
}

.login-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 4px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.2);
    margin-bottom: 24px;
}

.login-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.login-card-desc {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-bottom: 24px;
}

.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--gray-400);
}

.input-field {
    width: 100%;
    padding: 16px 16px 16px 48px;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    transition: all 0.2s;
    font-family: var(--font);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.input-field::placeholder {
    color: var(--gray-400);
}

.login-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 14px -4px rgba(37, 99, 235, 0.5);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(37, 99, 235, 0.6);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn svg {
    width: 20px;
    height: 20px;
}

/* Terms checkbox */
.terms-checkbox {
    margin-bottom: 20px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-text {
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.5;
}

.checkbox-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.checkbox-text a:hover {
    text-decoration: underline;
}

.login-help {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--gray-100);
    margin-top: 20px;
}

.login-help p {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.forgot-passkey-btn {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.forgot-passkey-btn:hover {
    background: var(--primary-50);
}

.login-footer {
    text-align: center;
    margin-top: auto;
    padding-bottom: 24px;
}

.login-footer p {
    font-size: 0.8rem;
    color: var(--gray-400);
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo svg {
    width: 24px;
    height: 24px;
    color: var(--white);
}

.header-info {
    display: flex;
    flex-direction: column;
}

.header-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--white);
}

.header-user {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-settings {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.header-settings:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(45deg);
}

.header-settings svg {
    width: 20px;
    height: 20px;
    color: var(--white);
}

/* ===== Main Content ===== */
.main-content {
    padding: 20px;
    background: linear-gradient(180deg, var(--primary-50) 0%, var(--white) 50%);
    min-height: calc(100vh - 72px);
}

/* ===== Connection Bar ===== */
.connection-bar {
    background: var(--white);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.connection-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--gray-400);
}

.connection-indicator.online .indicator-dot {
    background: var(--success);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

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

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

.indicator-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
}

.connection-indicator.online .indicator-text {
    color: var(--success);
}

/* ===== Status Row ===== */
.status-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.status-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow);
}

.status-icon {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--primary);
}

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

.status-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
}

.status-value.active {
    color: var(--success);
}

/* ===== GPS Card ===== */
.gps-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    color: var(--white);
}

.gps-icon {
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gps-icon svg {
    width: 28px;
    height: 28px;
    stroke: var(--white);
}

.gps-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gps-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

.gps-coords {
    font-size: 0.95rem;
    font-weight: 600;
    font-family: monospace;
}

/* ===== Alert Type Selector ===== */
.alert-type-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.type-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.type-chip:hover {
    border-color: var(--gray-300);
    transform: translateY(-1px);
}

.type-chip.selected {
    border-color: var(--primary);
    background: var(--primary-50);
    color: var(--primary-dark);
}

.type-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
}

.type-dot.emergency {
    background: #ef4444;
}

.type-dot.medical {
    background: #22c55e;
}

.type-dot.security {
    background: #f59e0b;
}

.type-dot.fire {
    background: #ff6b35;
}

.type-dot.accident {
    background: #8b5cf6;
}

.type-dot.facility {
    background: #14b8a6;
}

/* ===== Panic Button ===== */
.panic-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 30px;
}

.panic-ring {
    position: absolute;
    border-radius: var(--radius-full);
    border: 2px solid var(--danger-light);
    opacity: 0;
    animation: ring-pulse 3s ease-out infinite;
}

.ring-1 {
    width: 200px;
    height: 200px;
    animation-delay: 0s;
}

.ring-2 {
    width: 240px;
    height: 240px;
    animation-delay: 1s;
}

.ring-3 {
    width: 280px;
    height: 280px;
    animation-delay: 2s;
}

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

    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.panic-button {
    width: 180px;
    height: 180px;
    border-radius: var(--radius-full);
    border: none;
    background: linear-gradient(145deg, var(--danger-light) 0%, var(--danger) 50%, var(--danger-dark) 100%);
    cursor: pointer;
    position: relative;
    z-index: 10;
    box-shadow:
        0 15px 40px -10px rgba(220, 38, 38, 0.6),
        0 0 0 6px rgba(220, 38, 38, 0.2),
        inset 0 -6px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s;
}

.panic-button:hover {
    transform: scale(1.03);
    box-shadow:
        0 20px 50px -10px rgba(220, 38, 38, 0.7),
        0 0 0 8px rgba(220, 38, 38, 0.25),
        inset 0 -6px 20px rgba(0, 0, 0, 0.15);
}

.panic-button:active {
    transform: scale(0.96);
}

.panic-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.panic-icon {
    width: 48px;
    height: 48px;
    color: var(--white);
    margin-bottom: 8px;
}

.panic-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: 0.1em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.panic-hint {
    text-align: center;
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-top: 8px;
}

/* ===== Alert Active ===== */
.alert-active {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    color: var(--white);
    animation: slideUp 0.3s ease-out;
    margin-bottom: 24px;
}

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

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

.alert-header {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
}

.alert-pulse {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.2);
    animation: pulse-alert 1.5s ease-out infinite;
}

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

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

.alert-icon-wrap {
    width: 72px;
    height: 72px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.alert-icon-wrap svg {
    width: 36px;
    height: 36px;
    color: var(--white);
}

.alert-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.alert-subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.alert-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.alert-stat {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-icon {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: rgba(255, 255, 255, 0.9);
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 700;
}

.stat-value.recording::before {
    content: "●";
    margin-right: 4px;
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.cancel-countdown {
    text-align: center;
}

.cancel-countdown p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 12px;
}

.cancel-countdown strong {
    font-size: 1.1rem;
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: none;
    padding: 14px 32px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Alert Message Input ===== */
.alert-message-section {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
}

.message-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.alert-message-section textarea {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: var(--radius);
    padding: 12px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    color: var(--gray-800);
    min-height: 48px;
}

.alert-message-section textarea::placeholder {
    color: var(--gray-400);
}

.alert-message-section textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.send-message-btn {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-message-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

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

.send-message-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--white);
}

.message-status {
    display: block;
    font-size: 0.75rem;
    margin-top: 6px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
}

.message-status.sent {
    color: #86efac;
}

/* ===== Activity Section ===== */
.activity-section {
    margin-top: 24px;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.activity-list {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.activity-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--gray-400);
}

.empty-icon {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--success);
}

.empty-text {
    font-size: 0.9rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
}

.activity-item:last-child {
    border: none;
}

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

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

.activity-icon.success {
    background: var(--success-50);
}

.activity-icon.success svg {
    stroke: var(--success);
}

.activity-icon.warning {
    background: #fff3cd;
}

.activity-icon.warning svg {
    stroke: #856404;
}

.activity-icon.danger {
    background: var(--danger-50);
}

.activity-icon.danger svg {
    stroke: var(--danger);
}

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--gray-300);
    flex-shrink: 0;
}

.activity-dot.resolved {
    background: var(--success);
}

.activity-dot.cancelled {
    background: var(--gray-400);
}

.activity-dot.active {
    background: var(--danger);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
}

.activity-meta {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.activity-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-600);
}

.activity-status.resolved {
    background: var(--success-50);
    color: var(--success);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.modal.small {
    max-height: 60vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    position: sticky;
    top: 0;
    background: var(--white);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-200);
}

.modal-close svg {
    width: 18px;
    height: 18px;
    color: var(--gray-600);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* ===== Profile Section ===== */
.profile-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--primary-50);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 1.35rem;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.profile-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--gray-500);
    line-height: 1.5;
}

/* ===== Settings Group ===== */
.settings-group {
    margin-bottom: 24px;
}

.settings-group h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
}

.toggle-row span:first-child {
    font-size: 0.9rem;
    color: var(--gray-700);
}

.toggle-row input {
    display: none;
}

.toggle-switch {
    width: 48px;
    height: 28px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    position: relative;
    transition: all 0.2s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: var(--white);
    border-radius: var(--radius-full);
    top: 3px;
    left: 3px;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle-row input:checked+.toggle-switch {
    background: var(--primary);
}

.toggle-row input:checked+.toggle-switch::after {
    left: 23px;
}

.contacts-list {
    margin-bottom: 12px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    color: var(--white);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
}

.contact-phone {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.contact-delete {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all 0.2s;
}

.contact-delete:hover {
    background: var(--danger-50);
    color: var(--danger);
}

.contact-delete svg {
    width: 16px;
    height: 16px;
}

.add-contact-btn {
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--gray-300);
    background: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-500);
    transition: all 0.2s;
}

.add-contact-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.add-contact-btn svg {
    width: 20px;
    height: 20px;
}

.logout-btn {
    width: 100%;
    padding: 14px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--gray-200);
}

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

/* ===== Buttons ===== */
.btn-primary {
    padding: 12px 24px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-secondary {
    padding: 12px 24px;
    background: none;
    color: var(--gray-600);
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--gray-100);
}

/* ===== Permission Request ===== */
.permission-request {
    background: var(--warning-light);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.permission-icon {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.permission-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--primary);
}

.permission-text {
    flex: 1;
    min-width: 150px;
}

.permission-text strong {
    display: block;
    font-size: 0.9rem;
    color: var(--gray-800);
    margin-bottom: 2px;
}

.permission-text p {
    font-size: 0.8rem;
    color: var(--gray-700);
}

.permission-btn {
    padding: 10px 20px;
    background: var(--white);
    color: var(--gray-800);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.permission-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== Permission Rows in Settings ===== */
.permission-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.perm-icon {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.perm-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--primary);
}

.perm-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    flex: 1;
}

.perm-status {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--gray-200);
    color: var(--gray-600);
}

.perm-status.granted {
    background: var(--success-50);
    color: var(--success);
}

.perm-status.denied {
    background: var(--danger-50);
    color: var(--danger);
}

.perm-btn {
    padding: 6px 14px;
    background: var(--primary);
    color: var(--white);
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ===== Status Card Clickable ===== */
.status-card.clickable {
    cursor: pointer;
    transition: all 0.2s;
}

.status-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -4px rgba(0, 0, 0, 0.15);
}

.status-value.error {
    color: var(--danger);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: var(--white);
    padding: 14px 24px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===== Passkey Input ===== */
.passkey-input {
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
}

/* ===== Back Link ===== */
.back-link {
    display: block;
    margin-top: 16px;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

/* ===== Resend Passkey ===== */
.resend-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.resend-section p {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 10px;
}

.resend-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary-50);
    color: var(--primary);
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.resend-btn svg {
    width: 16px;
    height: 16px;
}

/* ===== Password Toggle (Resident App) ===== */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    transition: color 0.2s;
}

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

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

.password-wrapper .input-field {
    padding-right: 44px;
}

/* ===== Responsive ===== */
@media (min-width: 481px) {
    .modal {
        border-radius: var(--radius-lg);
        margin: auto;
    }

    .modal-overlay {
        align-items: center;
        padding: 20px;
    }
}

/* ===== HELP IS ON THE WAY Popup ===== */
.help-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.help-popup.hidden {
    display: none;
}

.help-popup-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    text-align: center;
    max-width: 340px;
    width: 90%;
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.help-popup-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: pulse 1.5s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-popup-icon svg {
    width: 64px;
    height: 64px;
    stroke: var(--danger);
}

.help-popup-content h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 12px;
}

.help-popup-content p {
    color: var(--gray-600);
    font-size: 15px;
    margin-bottom: 8px;
}

.help-popup-subtitle {
    color: var(--gray-500) !important;
    font-size: 13px !important;
}

.help-popup-dismiss {
    margin-top: 20px;
    padding: 14px 32px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.help-popup-dismiss:hover {
    background: var(--success-light);
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: rotate(15deg);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal);
}

.theme-toggle .sun-icon {
    display: block;
}

.theme-toggle .moon-icon {
    display: none;
}

.dark-theme .theme-toggle .sun-icon {
    display: none;
}

.dark-theme .theme-toggle .moon-icon {
    display: block;
}

/* Dark theme specific overrides - Glassmorphism Design */

/* Base container - plain dark background */
.dark-theme .app-container {
    background: #0a0f1a;
}

.dark-theme .main-content {
    background: #0a0f1a;
}

/* Header */
.dark-theme .header {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

/* Header logo - enhanced visibility */
.dark-theme .header-logo {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark-theme .header-logo svg {
    color: #ffffff;
    stroke-width: 2;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Settings button - enhanced visibility */
.dark-theme .header-settings {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark-theme .header-settings svg {
    color: #ffffff;
    stroke-width: 2;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.dark-theme .header-settings:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* GPS card icon - enhanced visibility */
.dark-theme .gps-icon {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dark-theme .gps-icon svg {
    stroke: #ffffff;
    stroke-width: 2;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

/* Header text - enhanced visibility */
.dark-theme .header-title {
    color: #ffffff;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.02em;
}

.dark-theme .header-user {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Glass card base */
.dark-theme .login-card,
.dark-theme .card,
.dark-theme .settings-section {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
}

.dark-theme .btn-secondary {
    background: rgba(30, 41, 59, 0.6);
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.dark-theme .btn-secondary:hover {
    background: rgba(51, 65, 85, 0.6);
}

/* Connection bar - glass card */
.dark-theme .connection-bar {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.dark-theme .indicator-text {
    color: #94a3b8;
}

.dark-theme .connection-indicator.online .indicator-text {
    color: #4ade80;
}

/* Status cards - glassmorphism */
.dark-theme .status-card {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.dark-theme .status-card .status-label {
    color: #64748b;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dark-theme .status-card .status-value {
    color: #f1f5f9;
    font-weight: 600;
}

.dark-theme .status-icon svg {
    stroke: #60a5fa;
}

/* GPS card - gradient glass */
.dark-theme .gps-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3) 0%, rgba(37, 99, 235, 0.4) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.dark-theme .gps-label {
    color: rgba(255, 255, 255, 0.8);
}

.dark-theme .gps-coords {
    color: #ffffff;
}

/* Alert type chips - glass style */
.dark-theme .type-chip {
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    transition: all 0.2s ease;
}

.dark-theme .type-chip:hover {
    background: rgba(51, 65, 85, 0.7);
    border-color: rgba(255, 255, 255, 0.15);
}

.dark-theme .type-chip.selected {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #93c5fd;
}

/* Activity section */
.dark-theme .section-title {
    color: #f1f5f9;
    font-weight: 600;
}

.dark-theme .activity-list {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    overflow: hidden;
}

.dark-theme .activity-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.dark-theme .activity-item:last-child {
    border-bottom: none;
}

.dark-theme .activity-title {
    color: #f1f5f9;
    font-weight: 500;
}

.dark-theme .activity-meta {
    color: #64748b;
}

.dark-theme .activity-icon {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.dark-theme .activity-icon.success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.2);
}

.dark-theme .activity-icon.success svg {
    stroke: #4ade80;
}

.dark-theme .activity-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.2);
}

.dark-theme .activity-icon.warning svg {
    stroke: #fbbf24;
}

.dark-theme .activity-icon.danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.2);
}

.dark-theme .activity-icon.danger svg {
    stroke: #f87171;
}

.dark-theme .activity-status {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
}

.dark-theme .activity-status.success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.dark-theme .activity-status.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.dark-theme .activity-status.danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.dark-theme .activity-status.muted {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
}

.dark-theme .activity-empty {
    color: #475569;
}

/* Modal overlay - darker */
.dark-theme .modal-overlay {
    background: rgba(0, 0, 0, 0.85);
}

/* Modal - glassmorphism */
.dark-theme .modal {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
}

.dark-theme .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dark-theme .modal-header h2 {
    color: #f1f5f9;
}

.dark-theme .modal-close {
    color: #64748b;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.dark-theme .modal-close:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.1);
}

/* Profile section */
.dark-theme .profile-section {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
}

.dark-theme .profile-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    box-shadow: 0 4px 18px rgba(102, 126, 234, 0.5);
}

.dark-theme .profile-name {
    color: #f1f5f9;
}

.dark-theme .profile-details span {
    color: #64748b;
}

/* Settings groups */
.dark-theme .settings-group h4 {
    color: #94a3b8;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.dark-theme .permission-row {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 10px;
}

.dark-theme .perm-icon svg {
    stroke: #64748b;
}

.dark-theme .perm-name {
    color: #e2e8f0;
}

.dark-theme .perm-status {
    color: #94a3b8;
    background: rgba(51, 65, 85, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-theme .perm-status.granted {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
    font-weight: 600;
}

.dark-theme .perm-status.denied {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    font-weight: 600;
}

.dark-theme .toggle-row {
    color: #e2e8f0;
}

/* Toggle switch */
.dark-theme .toggle-switch {
    background: rgba(100, 116, 139, 0.3);
}

/* Inputs - glass style */
.dark-theme .input-field {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    border-radius: 10px;
}

.dark-theme .input-field::placeholder {
    color: #475569;
}

.dark-theme .input-field:focus {
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dark-theme .input-label {
    color: #94a3b8;
}

.dark-theme .input-icon svg {
    stroke: #475569;
}

/* Logout button */
.dark-theme .logout-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-radius: 10px;
}

.dark-theme .logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Panic hint */
.dark-theme .panic-hint {
    color: #475569;
}

/* Toast - glass */
.dark-theme .toast {
    background: rgba(51, 65, 85, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

/* Contact items */
.dark-theme .contact-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.dark-theme .contact-name {
    color: #e2e8f0;
}

.dark-theme .contact-phone {
    color: #64748b;
}

/* Add contact button */
.dark-theme .add-contact-btn {
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

.dark-theme .add-contact-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.5);
}

/* Permission request card */
.dark-theme .permission-request {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.dark-theme .permission-text strong {
    color: #f1f5f9;
}

.dark-theme .permission-text p {
    color: #94a3b8;
}

.dark-theme .permission-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
}

/* Help Popup - Dark Theme */
.dark-theme .help-popup-content {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.dark-theme .help-popup-content h1 {
    color: #4ade80;
}

.dark-theme .help-popup-content p {
    color: #e2e8f0;
}

/* ===== Mobile Responsiveness Improvements ===== */

/* Safe area insets for notched devices (iPhone X+) */
.app-container {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.login-content {
    padding-bottom: env(safe-area-inset-bottom);
}

.main-content {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.modal {
    padding-bottom: env(safe-area-inset-bottom);
}

/* Responsive panic button with viewport scaling */
.panic-button {
    width: clamp(140px, 42vw, 180px);
    height: clamp(140px, 42vw, 180px);
}

.panic-text {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
}

.panic-icon {
    width: clamp(36px, 10vw, 48px);
    height: clamp(36px, 10vw, 48px);
}

/* Panic ring scaling */
.ring-1 {
    width: clamp(160px, 48vw, 200px);
    height: clamp(160px, 48vw, 200px);
}

.ring-2 {
    width: clamp(190px, 56vw, 240px);
    height: clamp(190px, 56vw, 240px);
}

.ring-3 {
    width: clamp(220px, 64vw, 280px);
    height: clamp(220px, 64vw, 280px);
}

/* Minimum touch target sizes (44px) */
.header-settings {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.modal-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.contact-delete {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
}

.type-chip {
    min-height: 44px;
    padding: 12px 18px;
}

.toggle-row {
    min-height: 48px;
}

.permission-btn {
    min-height: 44px;
    padding: 12px 20px;
}

.perm-btn {
    min-height: 44px;
    padding: 10px 16px;
}

/* Medium mobile breakpoint (480px) */
@media (max-width: 480px) {
    .login-content {
        padding: 24px 16px;
    }

    .login-header {
        padding-top: 24px;
        margin-bottom: 28px;
    }

    .login-title {
        font-size: 1.75rem;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 16px;
    }

    .login-card-title {
        font-size: 1.125rem;
    }

    .header-content {
        padding: 12px 0;
    }

    .header-title {
        font-size: 1rem;
    }

    .main-content {
        padding: 16px;
    }

    .panic-container {
        padding: 20px;
        margin: 12px 0;
    }

    .panic-hint {
        font-size: 0.85rem;
    }

    .alert-active {
        padding: 22px 20px;
        border-radius: 16px;
    }

    .alert-title {
        font-size: 1.1rem;
    }

    .alert-stats {
        gap: 8px;
    }

    .alert-stat {
        padding: 10px 8px;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stat-value {
        font-size: 0.85rem;
    }

    .gps-card {
        padding: 14px 16px;
    }

    .gps-coords {
        font-size: 0.85rem;
    }

    .status-row {
        gap: 10px;
    }

    .status-card {
        padding: 14px 12px;
        gap: 10px;
    }

    .status-value {
        font-size: 0.85rem;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .profile-section {
        padding: 16px;
        gap: 14px;
    }

    .profile-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }
}

/* Small mobile breakpoint (375px - iPhone SE and similar) */
@media (max-width: 375px) {
    .login-content {
        padding: 20px 14px;
    }

    .login-header {
        padding-top: 20px;
        margin-bottom: 24px;
    }

    .logo-shield {
        width: 68px;
        height: 68px;
    }

    .logo-shield svg {
        width: 38px;
        height: 38px;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .login-subtitle {
        font-size: 0.9rem;
    }

    .login-card {
        padding: 20px 16px;
    }

    .input-field {
        padding: 14px 14px 14px 44px;
        font-size: 0.95rem;
    }

    .login-btn {
        padding: 14px 20px;
        font-size: 0.95rem;
    }

    .checkbox-text {
        font-size: 0.8rem;
    }

    .header {
        padding: 0 14px;
    }

    .header-logo {
        width: 36px;
        height: 36px;
    }

    .header-title {
        font-size: 0.95rem;
    }

    .header-user {
        font-size: 0.75rem;
    }

    .main-content {
        padding: 14px;
    }

    .status-row {
        gap: 8px;
    }

    .status-card {
        padding: 12px 10px;
        gap: 8px;
    }

    .status-label {
        font-size: 0.7rem;
    }

    .status-value {
        font-size: 0.8rem;
    }

    .alert-type-selector {
        gap: 8px;
    }

    .type-chip {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .panic-container {
        padding: 16px;
        margin: 8px 0;
    }

    .alert-active {
        padding: 20px 16px;
    }

    .alert-icon-wrap {
        width: 60px;
        height: 60px;
    }

    .alert-icon-wrap svg {
        width: 30px;
        height: 30px;
    }

    .alert-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .alert-stat {
        padding: 8px 6px;
    }

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

    .cancel-btn {
        padding: 12px 24px;
        font-size: 0.9rem;
    }

    .gps-card {
        padding: 12px 14px;
        gap: 12px;
    }

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

    .gps-label {
        font-size: 0.75rem;
    }

    .gps-coords {
        font-size: 0.8rem;
    }

    .section-title {
        font-size: 0.95rem;
    }

    .activity-item {
        padding: 12px 14px;
        gap: 12px;
    }

    .activity-title {
        font-size: 0.85rem;
    }

    .activity-meta {
        font-size: 0.75rem;
    }

    .settings-group h4 {
        font-size: 0.85rem;
    }

    .contact-item {
        padding: 10px 14px;
    }

    .contact-name {
        font-size: 0.85rem;
    }

    .contact-phone {
        font-size: 0.75rem;
    }

    .help-popup-content {
        padding: 32px 24px;
    }

    .help-popup-content h1 {
        font-size: 20px;
    }
}

/* Very small screens (320px) */
@media (max-width: 320px) {
    .alert-stats {
        grid-template-columns: 1fr 1fr;
    }

    .alert-stat:last-child {
        grid-column: span 2;
    }

    .type-chip {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .login-card-title {
        font-size: 1rem;
    }

    .login-card-desc {
        font-size: 0.85rem;
    }
}