:root {
    --primary: #6C5CE7;
    --primary-hover: #5A4AD1;
    --bg-color: #0F0F13;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A5;
    --error: #FF4757;
    --success: #2ED573;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    position: relative;
    overflow-x: hidden;
}

.background-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(100px);
    opacity: 0.5;
    border-radius: 50%;
    animation: float 20s infinite ease-in-out;
}

.blob-1 {
    top: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #6C5CE7, transparent);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -20%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #00D2D3, transparent);
    animation-delay: -5s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(50px, 20px) scale(1.05); }
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-weight: 600;
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #FFF, #A0A0A5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

header.flex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    margin-bottom: 30px;
}

header.flex-header .header-content {
    text-align: left;
}

.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    transform: translateY(-5px);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5);
}

.input-group {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
}

.row {
    display: flex;
    gap: 20px;
}

.row .input-group {
    flex: 1;
}

label {
    font-size: 0.95rem;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
    background: rgba(0, 0, 0, 0.3);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

small {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

button[type="submit"] {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #8271FC);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(108, 92, 231, 0.3);
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(108, 92, 231, 0.4);
    background: linear-gradient(135deg, var(--primary-hover), #9788FA);
}

button[type="submit"]:active {
    transform: translateY(1px);
}

.loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
}

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

.hidden {
    display: none !important;
}

/* Complex Stats Progress Bars */
.progress-list-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.progress-list-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}
.progress-list-item-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    font-weight: 500;
}
.progress-list-item-value {
    font-weight: 600;
    margin-left: 10px;
    color: var(--text-primary);
}
.progress-bar-bg {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: #00D2D3;
    border-radius: 2px;
}
.progress-bar-fill.alt-color {
    background: var(--primary);
}
.progress-bar-fill.alt-color-2 {
    background: #2ed573;
}

/* Results section */
.result-container {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--surface-border);
    text-align: center;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.success-icon {
    width: 50px;
    height: 50px;
    background: rgba(46, 213, 115, 0.2);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 15px;
    border: 1px solid rgba(46, 213, 115, 0.3);
    box-shadow: 0 0 20px rgba(46, 213, 115, 0.2);
}

.result-container h3 {
    margin-bottom: 20px;
    font-weight: 400;
}

.link-display {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.link-display input {
    flex: 1;
    background: rgba(46, 213, 115, 0.05);
    border-color: rgba(46, 213, 115, 0.3);
    color: var(--success);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.link-display button {
    width: 100%;
    padding: 14px;
    background: rgba(46, 213, 115, 0.1);
    border: 1px solid rgba(46, 213, 115, 0.3);
    color: var(--success);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.link-display button:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(255,255,255,0.1);
}

.link-display button:active {
    transform: scale(0.95);
}

.error-message {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.3);
    border-radius: 12px;
    color: var(--error);
    text-align: center;
    font-size: 0.9rem;
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

@media (max-width: 600px) {
    .row {
        flex-direction: column;
        gap: 0;
    }
    .glass-panel {
        padding: 25px 15px;
    }
    header h1 {
        font-size: 2rem;
    }
    .mode-selector {
        flex-wrap: wrap;
        gap: 15px;
    }
    table th:nth-child(1) { width: 35%; }
    table th:nth-child(2) { width: 28%; }
    table th:nth-child(3) { width: 14%; text-align: center; }
    table th:nth-child(4) { width: 23%; text-align: right; }
    table th, table td {
        padding: 10px 4px;
        font-size: 0.8rem;
    }
    .action-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        display: inline-block;
        margin-bottom: 5px;
        width: 100%;
        text-align: center;
    }
    
    header.flex-header {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 15px;
        text-align: center;
    }
    header.flex-header .header-content {
        text-align: center;
    }
    header.flex-header button {
        width: 100%;
        padding: 12px;
    }
    
    /* Responsive Domain Stats Panel */
    #domainStats {
        flex-direction: column;
        align-items: stretch !important;
        padding: 20px 15px !important;
        gap: 15px !important;
    }
    
    #domainStats > div {
        flex-direction: column;
        justify-content: center !important;
        width: 100%;
        gap: 8px !important;
    }

    #domainStats > div > span {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }
    
    #domainStats button {
        width: 100%;
        justify-content: center;
        margin: 0 !important;
        padding: 12px !important;
    }

    /* Responsive Chart Header */
    .chart-header-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }

    .chart-period-container {
        width: 100%;
        justify-content: space-between !important;
    }
    .chart-period-container select {
        flex: 1;
        margin-left: 10px;
    }
    
    /* Metric Cards 2x2 Grid Layout for Mobile */
    #advancedStatsContainer > div:last-child {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    
    .stat-card {
        padding: 15px 12px !important;
    }
    .stat-card > div:first-child {
        font-size: 0.85rem !important;
        margin-bottom: 15px !important;
        line-height: 1.2;
    }
    .stat-card [id^="metric"] {
        font-size: 1.4rem !important;
    }
    
    #pagination-controls {
        flex-direction: column;
        align-items: stretch !important;
        gap: 15px;
    }
    
    #pagination-controls > div {
        width: 100%;
        justify-content: space-between;
    }
    /* Map Grid Mobile */
    .country-map-grid {
        grid-template-columns: 1fr !important;
    }
}
