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

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

:root {
    --primary: #1e3a8a;
    --primary-hover: #1e40af;
    --accent: #3b82f6;
    --success: #10b981;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(125deg, #627eff 0%, #5be5ad 100%) no-repeat fixed;
    background-size: cover;
    min-height: 100vh;
    color: var(--gray-900);
}

.navbar {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

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

.nav-links a {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

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

.nav-user {
    color: var(--gray-600);
    font-weight: 500;
}

.container {
    max-width: 1600px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.page-header {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.page-header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.main-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

/* Step Progress */
.step-progress {
    display: flex;
    background: var(--gray-100);
}

.step {
    flex: 1;
    padding: 1.5rem;
    text-align: center;
    background: var(--gray-100);
    color: var(--gray-600);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    clip-path: polygon(0 0, calc(100% - 30px) 0, 100% 50%, calc(100% - 30px) 100%, 0 100%);
    margin-right: -30px;
    position: relative;
}

.step:first-child {
    clip-path: polygon(0 0, calc(100% - 30px) 0, 100% 50%, calc(100% - 30px) 100%, 0 100%, 0 0);
}

.step:last-child {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 30px 50%);
    margin-right: 0;
}

.step.active {
    background: var(--primary);
    color: white;
    z-index: 2;
}

.step.completed {
    background: var(--accent);
    color: white;
    z-index: 1;
}

.form-content {
    padding: 3rem;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
}

h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--gray-600);
    margin-bottom: 2rem;
}

.form-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray-700);
}

input, select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

input:invalid {
    border-color: var(--danger);
}

input:invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.error-message {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
}

.input-group {
    position: relative;
}

.input-prefix {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-600);
    font-weight: 600;
}

.input-group input {
    padding-left: 2rem;
}

.toggle-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.toggle-btn {
    padding: 0.75rem;
    border: 2px solid var(--gray-300);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--gray-200);
}

.btn {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

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

.card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

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

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.summary-card h3 {
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.summary-card .value {
    font-size: 1.8rem;
    font-weight: 700;
}

.comparison-table {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.comparison-table table {
    width: 100%;
    border-collapse: collapse;
}

.comparison-table th {
    background: var(--primary);
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.comparison-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.comparison-table tbody tr:hover {
    background: var(--gray-50);
}

.positive { color: var(--success); font-weight: 600; }
.negative { color: var(--danger); font-weight: 600; }

.year-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.year-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.year-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.property-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

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

.property-card h3 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.property-info {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-200);
}

.property-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid var(--success);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid var(--danger);
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 100%;
}

.auth-card h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 2rem;
}

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

.metric-box {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.metric-box .label {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.metric-box .value {
    font-size: 1.3rem;
    font-weight: 700;
}

/* ==================== MOBILE RESPONSIVE ==================== */

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.8rem;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    
    .comparison-table {
        overflow-x: auto;
    }
    
    .comparison-table table {
        min-width: 600px;
    }
    
    .properties-grid {
        grid-template-columns: 1fr;
    }
    
    .metric-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-container {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
    
    .nav-brand h1 {
        font-size: 1.3rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .property-card {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Stack buttons vertically on mobile */
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Year range buttons */
    .year-range-buttons {
        flex-wrap: wrap;
    }
    
    .year-range-buttons button {
        flex: 1 1 45%;
    }
    
    /* Property actions */
    .property-actions {
        flex-direction: column;
    }
    
    .property-actions .btn {
        width: 100%;
    }
    
    /* Dashboard quick actions */
    .container > .card:last-child > div:last-child {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Hide desktop-only elements */
    .nav-user {
        display: none;
    }
}

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .summary-card .value {
        font-size: 2rem;
    }
    
    .nav-brand h1 {
        font-size: 1.1rem;
    }
    
    /* Stack all buttons */
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .hero-btn {
        width: 100%;
    }
    
    /* Dashboard quick actions - 1 column on tiny screens */
    .container > .card:last-child > div:last-child {
        grid-template-columns: 1fr !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-grid.grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    .form-actions,
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
