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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

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

header {
    position: relative;
    color: white;
    margin-bottom: 30px;
    text-align: center;
}

/* Desktop: Logo in top-left corner */
@media (min-width: 1024px) {
    header {
        text-align: left;
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        margin-bottom: 20px;
    }
    
    .header-left {
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    .header-center {
        flex: 1;
        text-align: center;
        margin-top: 10px;
    }
}

.logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

@media (min-width: 1024px) {
    .logo {
        max-width: 120px;
        margin-bottom: 0;
    }
}

h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

@media (min-width: 1024px) {
    h1 {
        font-size: 2em;
        margin-bottom: 5px;
    }
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

/* Desktop: 3-column layout */
@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 15px;
        margin-bottom: 20px;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    header {
        text-align: center;
        display: block;
    }
    
    .header-left {
        display: block;
        text-align: center;
        margin-bottom: 15px;
    }
    
    .header-center {
        margin-top: 0;
    }
}

.card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.form-section {
    display: none;
}

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

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

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: #667eea;
}

.radio-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    margin-top: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary {
    background: #6c757d;
    font-size: 14px;
    padding: 10px 20px;
    margin-top: 10px;
}

.results {
    margin-top: 30px;
}

.city-info {
    margin: 15px 0;
}

.city-info h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.population-display {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.score-display {
    text-align: center;
    margin-bottom: 30px;
}

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

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    font-weight: bold;
}

.recommendation {
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.recommendation.excellent {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.recommendation.good {
    background: #cfe2ff;
    color: #084298;
    border: 2px solid #b6d4fe;
}

.recommendation.moderate {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffecb5;
}

.recommendation.poor {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.breakdown {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

@media (max-width: 1023px) {
    .breakdown-card {
        /* Hide breakdown card on tablet/mobile - show inline instead */
        display: none;
    }
}

.breakdown-item {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
    position: relative;
}

.breakdown-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 10px;
}

.breakdown-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: help;
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.score-text-score {
    text-align: right;
    pointer-events: none;
}

.score-labels {
    text-align: center;
    margin-top: 10px;
}

.score-label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    letter-spacing: 1px;
    display: block;
}

.score-sublabel {
    font-size: 9px;
    color: #888;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-top: 2px;
    display: block;
}

.accuracy-indicator {
    margin: 20px 0;
    padding: 18px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 10px;
    border-left: 6px solid #dee2e6;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.accuracy-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.accuracy-label {
    font-size: 15px;
    color: #343a40;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.accuracy-level {
    font-size: 22px;
    font-weight: 700;
}

.accuracy-text {
    font-size: 14px;
    color: #495057;
    line-height: 1.5;
}

.accuracy-population {
    display: inline-block;
    margin-top: 6px;
    font-weight: 600;
    color: #212529;
    background: rgba(0, 0, 0, 0.04);
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: 6px;
}

.recommendation-box {
    margin: 20px 0;
    padding: 20px;
    border-radius: 8px;
    border-left: 5px solid;
    background: #f8f9fa;
}

.recommendation-box.excellent {
    border-left-color: #28a745;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
}

.recommendation-box.good {
    border-left-color: #17a2b8;
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
}

.recommendation-box.moderate {
    border-left-color: #ffc107;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
}

.recommendation-box.poor {
    border-left-color: #dc3545;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
}

.recommendation-text {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.revenue-estimate {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
}

.confidence {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.action-text {
    font-size: 14px;
    color: #495057;
    font-style: italic;
    line-height: 1.4;
}

.scale-container {
    position: relative;
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 5px;
}

.scale-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: 12px;
    transition: width 1s ease-out, background-color 0.5s ease;
}

.scale-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    display: flex;
}

.scale-marker {
    flex: 1;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.scale-marker:last-child {
    border-right: none;
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    font-size: 11px;
    font-weight: bold;
    cursor: help;
    position: relative;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
}

.score-number {
    font-size: 48px;
    font-weight: bold;
    color: #333;
    display: block;
}

.tooltip {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    max-width: 450px;
    white-space: normal;
    line-height: 1.6;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    font-weight: 500;
}

.tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #333;
}

.breakdown-label:hover .tooltip {
    opacity: 1;
}

@media (max-width: 768px) {
    .tooltip {
        left: auto;
        right: 0;
        top: -5px;
        transform: translateY(-100%);
        max-width: 320px;
        padding: 14px 18px;
        font-size: 14px;
    }
    
    .tooltip::before {
        right: 20px;
        top: 100%;
        border-right-color: transparent;
        border-top-color: #333;
    }
}

.demographics-display {
    background: #e8f4f8;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.demographics-display h4 {
    color: #0066cc;
    margin-bottom: 10px;
}

.demo-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.history {
    margin-top: 30px;
}

.history-item {
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.3s;
}

.history-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

.history-header:hover {
    background: #e9ecef;
}

.history-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: #fff;
    border-top: 1px solid #dee2e6;
}

.history-details.active {
    max-height: 500px;
    transition: max-height 0.5s ease-in;
}

.history-details-content {
    padding: 15px;
}

.load-history-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.load-history-btn:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.load-history-btn:active {
    transform: scale(0.95);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-row:last-child {
    border-bottom: none;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.pagination button:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-weight: 500;
    color: #666;
}

.expand-icon {
    transition: transform 0.3s;
    color: #667eea;
}

.history-item.expanded .expand-icon {
    transform: rotate(180deg);
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

.info-box {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.error-box {
    background: #ffebee;
    border-left: 4px solid #f44336;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    display: none;
}

.api-setup {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    font-size: 14px;
}

.api-setup a {
    color: #ff6f00;
    font-weight: 600;
}

.footer {
    margin-top: 50px;
    padding: 40px 30px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.footer p {
    color: white;
    font-size: 16px;
    font-weight: 300;
    letter-spacing: 0.5px;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.footer a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border-bottom: 1px solid transparent;
}

.footer a:hover {
    border-bottom: 1px solid white;
}

.clear-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 10px;
    transition: all 0.3s;
}

.clear-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.formula-section {
    margin-top: 30px;
    clear: both;
}

.accordion {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.accordion-header {
    padding: 25px 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.accordion-header:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.accordion-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #667eea;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out;
    background: #ffffff;
}

.accordion-content.active {
    max-height: 3000px;
    transition: max-height 0.8s ease-in;
}

.accordion-body {
    padding: 40px;
    line-height: 1.8;
    color: #444;
}

.accordion-body h3 {
    color: #667eea;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.accordion-body p {
    margin-bottom: 15px;
    font-size: 16px;
}

.formula-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin: 30px 0;
}

@media (max-width: 768px) {
    .formula-grid {
        grid-template-columns: 1fr;
    }
}

.formula-factor {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    border-left: 4px solid #667eea;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.formula-factor h4 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1.2em;
}

.score-range {
    margin: 10px 0;
    padding: 10px 12px;
    background: white;
    border-radius: 6px;
    font-size: 14px;
    border: 1px solid #e9ecef;
}

.whale-section {
    background: #e8f4f8;
    padding: 30px;
    border-radius: 12px;
    margin: 30px 0;
    border: 1px solid #b8dae6;
}

.whale-section h4 {
    color: #0066cc;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.whale-section ul {
    margin-left: 0;
    padding-left: 0;
    list-style: none;
}

.whale-section li {
    margin: 12px 0;
    padding-left: 30px;
    position: relative;
}

.whale-section li::before {
    content: "🐋";
    position: absolute;
    left: 0;
    top: 0;
}

.validation-section {
    background: #f0f7ff;
    padding: 30px;
    border-radius: 12px;
    margin: 30px 0;
    border: 1px solid #d0e4ff;
}

.validation-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.validation-list li {
    margin: 15px 0;
    padding-left: 30px;
    position: relative;
}

.validation-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #28a745;
    font-weight: bold;
    font-size: 20px;
}

.breakdown-item .score-text {
    font-weight: 600;
    font-size: 13px;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}

.whale-insight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.whale-insight p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.key-insight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin: 30px 0;
    text-align: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.key-insight p {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.history-collapsed {
    display: none;
}

.tip-box {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.tip-box strong {
    color: #667eea;
    display: block;
    margin-bottom: 8px;
}

.tip-box p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #555;
}
