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

:root {
    --primary: #5b5fc7;
    --primary-dark: #4338ca;
    --success: #10b981;
    --danger: #ef4444;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #4c1d95 0%, #3b0764 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.alert {
    position: fixed !important;
    top: 80px !important;
    right: 20px !important;
    left: auto !important;
    max-width: 350px !important;
    width: auto !important;
    padding: 1rem 1.5rem !important;
    margin: 0 !important;
    border-radius: 15px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
    z-index: 9999 !important;
    animation: slideIn 0.3s ease-out !important;
}

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(400px); opacity: 0; }
}

.alert.hiding { animation: slideOut 0.3s ease-in forwards !important; }
.alert-success { background: rgba(16, 185, 129, 0.25) !important; border: 1px solid var(--success) !important; }
.alert-error { background: rgba(239, 68, 68, 0.25) !important; border: 1px solid var(--danger) !important; }
.alert-info { background: rgba(99, 102, 241, 0.25) !important; border: 1px solid var(--primary) !important; }

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }
.auth-container { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.auth-card { max-width: 500px; width: 100%; }
.auth-card h1 { font-size: 2rem; margin-bottom: 0.5rem; text-align: center; }
.subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 2rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.5rem; }
.form-group { display: flex; flex-direction: column; }
.form-group label { margin-bottom: 0.5rem; font-weight: 500; color: var(--text-primary); }
.form-group input { 
    padding: 0.75rem; 
    border: 1px solid var(--glass-border); 
    border-radius: 10px; 
    background: rgba(255, 255, 255, 0.12); 
    color: var(--text-primary); 
    font-size: 1rem; 
}
.form-group input:focus { outline: none; border-color: var(--primary); background: rgba(255, 255, 255, 0.18); }

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5); }
.btn-secondary { background: rgba(255, 255, 255, 0.12); color: var(--text-primary); border: 1px solid var(--glass-border); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-small { padding: 0.5rem 1rem; font-size: 0.875rem; }

.auth-link { text-align: center; margin-top: 1rem; color: var(--text-secondary); }
.auth-link a { color: #a5b4fc; text-decoration: none; }
.empty-state { text-align: center; padding: 3rem 2rem; }
.empty-state h2 { margin-bottom: 1rem; }
.empty-state p { color: var(--text-secondary); margin-bottom: 1.5rem; }

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card { text-align: center; }
.stat-card h3 { color: var(--text-secondary); font-size: 1rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: bold; }

.glass-nav {
    background: rgba(59, 7, 100, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

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

.nav-brand { 
    font-size: 1.5rem; 
    font-weight: bold; 
    color: var(--text-primary); 
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.nav-logo {
    width: 32px;
    height: 32px;
}

/* Navigation Search */
.nav-search {
    flex: 0 1 400px;
    min-width: 200px;
}

.nav-search-form {
    display: flex;
    gap: 0.5rem;
}

.nav-search-input {
    flex: 1;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s;
}

.nav-search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.nav-search-input::placeholder {
    color: var(--text-secondary);
}

.nav-search-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.3s;
}

.nav-search-btn:hover {
    opacity: 0.7;
}

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

.nav-links a { 
    color: var(--text-primary); 
    text-decoration: none; 
    transition: opacity 0.3s; 
    font-weight: 500;
    white-space: nowrap;
}

.nav-links a:hover { opacity: 0.7; }

.metrics-section {
    padding: 2rem;
    margin-top: 0;
    margin-bottom: 2rem;
    max-height: 550px !important;
    overflow: hidden !important;
}

.metrics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.metrics-header h2 { margin: 0; }
.metrics-controls { display: flex; gap: 1rem; }

.metric-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    min-width: 150px;
    font-weight: 500;
}

.metric-select:focus { outline: none; border-color: var(--primary); background: rgba(255, 255, 255, 0.18); }
.metric-select option { background: #3b0764; color: white; }

.charts-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
    height: 380px !important;
    max-height: 380px !important;
}

.chart-box {
    background: rgba(255, 255, 255, 0.06);
    padding: 1rem;
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    height: 380px !important;
    max-height: 380px !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

.chart-box h3 { margin: 0 0 1rem 0; font-size: 1rem; text-align: center; flex-shrink: 0; }
.chart-box canvas { max-width: 100% !important; max-height: 320px !important; height: 320px !important; }
.chart-box-wide { height: 380px !important; max-height: 380px !important; }

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.category-card { text-decoration: none; color: inherit; cursor: pointer; transition: all 0.3s ease; display: block; }
.category-card:hover { transform: translateY(-5px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); }
.category-content h3 { margin-bottom: 0.5rem; font-size: 1.3rem; }
.category-description { color: var(--text-secondary); font-size: 0.9rem; margin: 0.5rem 0 1rem; }
.category-amount { font-size: 2rem; font-weight: bold; color: var(--success); margin: 1rem 0; }
.category-info { color: var(--text-secondary); font-size: 0.85rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.form-group textarea { padding: 0.75rem; border: 1px solid var(--glass-border); border-radius: 10px; background: rgba(255, 255, 255, 0.12); color: var(--text-primary); font-size: 1rem; font-family: inherit; resize: vertical; }
.form-group textarea:focus { outline: none; border-color: var(--primary); background: rgba(255, 255, 255, 0.18); }
.form-group input[type="color"] { height: 50px; cursor: pointer; }
.form-actions { display: flex; gap: 1rem; justify-content: flex-end; margin-top: 1rem; }
input[type="file"] { padding: 0.5rem; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--glass-border); border-radius: 10px; color: var(--text-primary); }

@media (max-width: 1024px) {
    .charts-container { grid-template-columns: 1fr; height: auto !important; }
    .chart-box { height: 350px !important; }
    .metrics-controls { flex-direction: column; width: 100%; }
    .metric-select { width: 100%; }
    .nav-container { flex-direction: column; gap: 1rem; }
}

/* SETTINGS PAGE */
.settings-container {
    max-width: 1000px;
    margin: 0 auto;
}

.settings-container h1 {
    margin-bottom: 2rem;
    font-size: 2rem;
}

.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--glass-border);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.tag-item {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tag-name {
    font-weight: 500;
    font-size: 1.1rem;
}

.empty-message {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

.users-table th,
.users-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.users-table th {
    font-weight: 600;
    color: var(--text-secondary);
}

.users-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-card h1 {
    margin-bottom: 2rem;
    font-size: 1.8rem;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

@media (max-width: 768px) {
    .settings-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
        text-align: left;
    }
    
    .users-table {
        font-size: 0.875rem;
    }
    
    .users-table th,
    .users-table td {
        padding: 0.5rem;
    }
}

/* FINA Logo Styling */
.nav-logo {
    height: 32px;
    width: 32px;
    margin-right: 0.5rem;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand span {
    font-size: 1.5rem;
    font-weight: bold;
}

/* Language Switcher */
.language-switcher {
    position: relative;
    display: inline-block;
    z-index: 9999;
}

.language-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.2s;
}

.language-btn:hover {
    transform: scale(1.1);
}

.language-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    min-width: 150px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    overflow: hidden;
}

.language-menu.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

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

.language-option {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
}

.language-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* PWA Install Prompt Styles */
.pwa-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 500px;
    width: calc(100% - 40px);
    z-index: 10000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.pwa-prompt-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.pwa-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

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

.pwa-prompt-text h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.pwa-prompt-text p {
    margin: 0.25rem 0 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pwa-prompt-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.pwa-prompt-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .pwa-prompt-content {
        flex-direction: column;
        text-align: center;
    }
    
    .pwa-prompt-actions {
        margin-left: 0;
        width: 100%;
    }
    
    .pwa-prompt-actions .btn {
        flex: 1;
    }
}

/* Enhanced Mobile Responsiveness for PWA */
@media (max-width: 768px) {
    /* Larger touch targets for mobile */
    .btn {
        min-height: 44px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .btn-small {
        min-height: 40px;
        padding: 0.625rem 1.25rem;
    }
    
    /* Stack header actions vertically on mobile */
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch !important;
    }
    
    .header-actions {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .header-actions .btn,
    .header-actions form {
        width: 100%;
    }
    
    .header-actions form button {
        width: 100%;
    }
    
    /* Navigation adjustments for mobile */
    .nav-container {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .nav-brand {
        font-size: 1.2rem;
    }
    
    .nav-logo {
        width: 28px;
        height: 28px;
    }
    
    .nav-search {
        order: 3;
        flex: 1 1 100%;
        max-width: 100%;
    }
    
    .nav-search-input {
        padding: 0.625rem 1rem;
        min-height: 44px;
    }
    
    .nav-links {
        gap: 0.75rem;
        font-size: 0.9rem;
    }
    
    .nav-links a {
        padding: 0.5rem 0.75rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        min-height: 40px;
        display: flex;
        align-items: center;
    }
    
    /* Better mobile navigation */
    .nav-links {
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: center;
    }
    
    .nav-links a {
        padding: 0.5rem 0.75rem;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        min-height: 40px;
        display: flex;
        align-items: center;
    }
    
    /* Subscription cards mobile-friendly */
    .subscription-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }
    
    .subscription-info {
        width: 100%;
    }
    
    .subscription-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }
    
    .subscription-actions .btn,
    .subscription-actions form {
        flex: 1;
    }
    
    /* Stats grid mobile */
    .stats-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Form improvements */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents iOS zoom */
        min-height: 44px;
    }
    
    /* Categories grid mobile */
    .categories-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Suggestion cards mobile */
    .suggestion-details {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }
    
    .suggestion-actions {
        flex-direction: column !important;
        width: 100%;
    }
    
    .suggestion-actions .btn,
    .suggestion-actions form {
        width: 100% !important;
    }
}
