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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --success-dark: #059669;
    --danger-color: #ef4444;
    --danger-dark: #dc2626;
    --warning-color: #f59e0b;
    --warning-dark: #d97706;
    --info-color: #3b82f6;
    --bg-color: #f8fafc;
    --bg-secondary: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #475569;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    background-attachment: fixed;
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    touch-action: pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-light);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.usd-rate {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    position: relative;
    width: 40px;
    height: 40px;
    justify-content: center;
    align-items: center;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.mobile-menu-overlay.active {
    opacity: 1;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: block;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

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

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-size: 0.9375rem;
    font-weight: 500;
    position: relative;
}

.nav-link:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

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

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.nav-user span {
    color: var(--text-light);
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Messages */
.messages {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: var(--success-color);
    color: #065f46;
}

.alert-error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: var(--danger-color);
    color: #991b1b;
}

.alert-info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: var(--info-color);
    color: #1e40af;
}

.alert-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: var(--warning-color);
    color: #92400e;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 2px solid var(--border-light);
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    transition: all 0.5s ease;
}

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

.stat-card:hover::before {
    top: -30%;
    right: -30%;
}

.stat-card.success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
}

.stat-card.danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-dark) 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, var(--warning-dark) 100%);
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.95;
    margin-bottom: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    word-break: break-word;
    line-height: 1.2;
    letter-spacing: -1px;
}

.stat-unit {
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border-radius: 0.75rem;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9375rem;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, var(--danger-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

/* Forms */
.form-group {
    margin-bottom: 1.75rem;
}

.form-label {
    display: block;
    margin-bottom: 0.625rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9375rem;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.form-actions .btn {
    flex: 1;
    min-width: 140px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 1px solid var(--border-light);
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--card-bg);
    border-radius: 0.75rem;
    overflow: hidden;
}

thead {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-color) 100%);
}

th, td {
    padding: 1.125rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    word-break: break-word;
}

th {
    font-weight: 700;
    color: var(--text-color);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: var(--bg-secondary);
    transform: scale(1.01);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.badge-danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
}

.badge-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.badge-info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
}

/* AI Analysis */
.ai-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2.5rem;
    border-radius: 1.25rem;
    box-shadow: var(--shadow-xl);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.ai-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
}

.ai-card h2 {
    margin-bottom: 1.25rem;
    font-size: 1.75rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.ai-response {
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 1.75rem;
    border-radius: 0.75rem;
    margin-top: 1.25rem;
    line-height: 1.9;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-wrap: break-word;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 1.5rem;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-weight: 700;
}

.empty-state-text {
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-light);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Auth Pages */
.auth-container {
    max-width: 480px;
    margin: 4rem auto;
    padding: 0 1rem;
}

.auth-card {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 1.25rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-light);
}

.auth-title {
    font-size: 2.25rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

.auth-divider {
    text-align: center;
    margin: 2rem 0;
    color: var(--text-light);
    position: relative;
    font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}

.auth-divider::before {
    left: 0;
}

.auth-divider::after {
    right: 0;
}

/* Responsive */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
        padding: 0 1.25rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

@media (max-width: 992px) {
    .mobile-menu-overlay {
        display: block;
    }
    
.nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    flex-direction: column;
    align-items: flex-start;
    padding: 5rem 2rem 2rem;
    gap: 0.5rem;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto;
    border-left: 1px solid var(--border-light);
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}
    
    .nav-menu.active {
        right: 0;
    }
    
    .nav-menu .nav-link {
        width: 100%;
        padding: 1rem 1.25rem;
        border-radius: 0.75rem;
        font-size: 1rem;
    }
    
    .nav-user {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        padding: 1.5rem 0 0;
        border-left: none;
        border-top: 2px solid var(--border-light);
        gap: 1rem;
    }
    
    .nav-user span {
        width: 100%;
        word-break: break-all;
        font-size: 0.9375rem;
    }
    
    .nav-user .btn {
        width: 100%;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .usd-rate {
        font-size: 0.8125rem;
        margin-right: auto;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .stat-card {
        padding: 1.75rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .card-title {
        font-size: 1.25rem;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.875rem;
        min-width: 600px;
    }
    
    th, td {
        padding: 0.875rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .main-content {
        padding: 1.5rem 0;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .auth-container {
        margin: 2rem auto;
        padding: 0 1rem;
    }
    
    .auth-card {
        padding: 2rem;
    }
    
    .auth-title {
        font-size: 1.875rem;
    }
    
    .ai-card {
        padding: 2rem;
    }
    
    .ai-card h2 {
        font-size: 1.5rem;
    }
    
    .ai-response {
        padding: 1.5rem;
        font-size: 0.9375rem;
    }
    
    .empty-state {
        padding: 3rem 1rem;
    }
    
    .empty-state-icon {
        font-size: 4rem;
    }
}

@media (max-width: 640px) {
    .nav-brand a {
        font-size: 1.25rem;
    }
    
    .nav-menu {
        width: 100%;
        max-width: 100vw;
    }
    
    .usd-rate {
        font-size: 0.75rem;
        order: -1;
        width: 100%;
        margin-bottom: 0.5rem;
        text-align: center;
    }
    
    .stats-grid {
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    .stat-label {
        font-size: 0.8125rem;
    }
    
    .card {
        padding: 1.25rem;
        border-radius: 0.875rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    .alert {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    th {
        font-size: 0.6875rem;
        padding: 0.75rem 0.5rem;
    }
    
    td {
        font-size: 0.8125rem;
        padding: 0.75rem 0.5rem;
    }
    
    .badge {
        font-size: 0.6875rem;
        padding: 0.25rem 0.625rem;
    }
    
    .main-content {
        padding: 1rem 0;
    }
    
    .container {
        padding: 0 0.875rem;
    }
    
    .ai-card {
        padding: 1.5rem;
    }
    
    .ai-card h2 {
        font-size: 1.25rem;
    }
    
    .ai-response {
        padding: 1.25rem;
        font-size: 0.875rem;
    }
    
    .form-control {
        padding: 0.75rem 0.875rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    .stat-value {
        font-size: 1.5rem;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .auth-card {
        padding: 1.5rem;
    }
    
    .auth-title {
        font-size: 1.625rem;
    }
}

/* Profile Tabs */
.profile-tab {
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-block;
}

.profile-tab:hover {
    color: var(--primary-color);
    background: var(--bg-secondary);
}

.profile-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

@media (max-width: 640px) {
    .profile-tab {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
}
