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

:root {
    --primary-color: #6200ee;
    --primary-dark: #5000ca;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --bg-gray: #f8f9fa;
    --border-color: #dadce0;
    --success-color: #0cce6b;
    --warning-color: #ffa400;
    --error-color: #ff4e42;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg-gray);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    padding: 60px 20px 40px;
}

.title {
    font-size: 3rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Input Section */
.input-section {
    max-width: 700px;
    margin: 0 auto 60px;
}

.input-wrapper {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.url-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
    font-family: 'Roboto', sans-serif;
}

.url-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(98, 0, 238, 0.1);
}

.analyze-btn {
    padding: 14px 32px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    position: relative;
}

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

.analyze-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-loader {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Device Toggle */
.device-toggle {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.device-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.device-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

/* Results Section */
.results-section {
    animation: fadeIn 0.5s ease;
}

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

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.results-header h2 {
    font-size: 1.5rem;
    font-weight: 400;
    color: white (--text-primary);
    word-break: break-all;
}

.new-analysis-btn {
    padding: 10px 20px;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* Loading Section */
.loading-section {
    max-width: 600px;
    margin: 40px auto;
    animation: fadeIn 0.5s ease;
}

.loading-card {
    background: white;
    border-radius: 12px;
    padding: 50px 40px;
    text-align: center;
    box-shadow: var(--shadow);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-gray);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

.loading-title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.loading-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.loading-progress {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: var(--bg-gray);
    border-radius: 8px;
    min-width: 150px;
}

.progress-step.loading {
    background: #e8f5e9;
    border: 2px solid var(--success-color);
}

.progress-step.completed {
    background: #e8f5e9;
}

.step-icon {
    font-size: 2rem;
}

.step-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.step-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-step.loading .step-status {
    color: var(--primary-color);
}

.progress-step.completed .step-status {
    color: var(--success-color);
}

/* Results Actions */
.results-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.results-device-toggle {
    margin: 0;
}

/* Score Circle */
.score-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.score-card {
    background: white;
    border-radius: 12px;
    padding: 30px 20px;
    box-shadow: var(--shadow);
    text-align: center;
}

.score-card h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.score-circle {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto;
}

.circle-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.circle-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 12;
}

.circle-progress {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 1s ease, stroke 0.3s ease;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 500;
}

/* Metrics Section */
.metrics-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.metrics-section h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.metric-item {
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid;
    background: var(--bg-gray);
}

.metric-item.good {
    border-color: var(--success-color);
}

.metric-item.needs-improvement {
    border-color: var(--warning-color);
}

.metric-item.poor {
    border-color: var(--error-color);
}

.metric-title {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.metric-rating {
    font-size: 0.875rem;
    font-weight: 500;
}

.metric-rating.good { color: var(--success-color); }
.metric-rating.needs-improvement { color: var(--warning-color); }
.metric-rating.poor { color: var(--error-color); }

/* Metrics List */
.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-gray);
    border-radius: 8px;
}

.metric-row-title {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.metric-row-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Opportunities & Diagnostics */
.opportunities-section,
.diagnostics-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.opportunities-section h3,
.diagnostics-section h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.opportunities-list,
.diagnostics-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.opportunity-item,
.diagnostic-item {
    padding: 20px;
    background: var(--bg-gray);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.opportunity-header,
.diagnostic-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 15px;
}

.opportunity-title,
.diagnostic-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}

.savings {
    font-size: 0.875rem;
    color: var(--success-color);
    font-weight: 500;
    white-space: nowrap;
}

.opportunity-description,
.diagnostic-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.no-items {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Error Section */
.error-section {
    max-width: 600px;
    margin: 40px auto;
}

.error-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow);
}

.error-card h3 {
    font-size: 1.5rem;
    color: var(--error-color);
    margin-bottom: 15px;
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 1rem;
}

.retry-btn {
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* Responsive */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .input-container {
        flex-direction: column;
    }

    .analyze-btn {
        width: 100%;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-header h2 {
        font-size: 1.25rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .score-container {
        grid-template-columns: 1fr 1fr;
    }

    .loading-progress {
        flex-direction: column;
    }

    .results-actions {
        width: 100%;
    }

    .results-device-toggle {
        width: 100%;
    }

    .results-device-toggle .device-btn {
        flex: 1;
    }

    .opportunity-header,
    .diagnostic-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
