* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a1a2e;
    --secondary: #16213e;
    --accent: #e94560;
    --accent-light: #f39c12;
    --text: #eee;
    --text-muted: #aaa;
    --border: #16213e;
    --success: #27ae60;
    --danger: #e74c3c;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* NAVBAR */
.navbar {
    background: rgba(26, 26, 46, 0.95);
    border-bottom: 2px solid var(--accent);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-brand h1 {
    font-size: 1.8rem;
    color: var(--accent);
    font-weight: bold;
}

.nav-top {
    display: flex;
    align-items: center;
}

.nav-mobile-panel {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-grow: 1;
}

.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--accent);
    background: rgba(233, 69, 96, 0.12);
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle-bar {
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
}

.nav-links {
    display: flex;
    gap: 2rem;
    flex-grow: 1;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.nav-links a:hover {
    background: var(--accent);
    color: white;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(39, 174, 96, 0.1);
    border-radius: 20px;
    border: 1px solid var(--success);
}

.donate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--accent-light);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.donate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(233, 69, 96, 0.35);
}

.donate-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.donate-info-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--accent-light);
    background: rgba(243, 156, 18, 0.15);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.donate-info-popover {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(320px, 80vw);
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--accent-light);
    background: rgba(10, 14, 28, 0.96);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.35;
    z-index: 150;
}

.donate-wrap.open .donate-info-popover {
    display: block;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

.status-dot.error {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* MAIN CONTENT */
.main-content {
    padding: 2rem;
    min-height: calc(100vh - 80px);
}

#content-area {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* HERO SECTION */
.hero {
    text-align: center;
    padding: 3rem 0;
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.1), rgba(243, 156, 18, 0.1));
    border-radius: 10px;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.hero h2 {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.1), rgba(243, 156, 18, 0.05));
    border: 1px solid var(--accent);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-light);
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.2);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.stat-number {
    font-size: 2.5rem;
    color: var(--accent);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-text {
    font-size: 1.3rem;
    color: var(--accent-light);
    margin-bottom: 0.5rem;
}

.stat-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* QUICK LINKS */
.quick-links {
    margin: 2rem 0;
}

.quick-links h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.link-btn {
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.link-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(233, 69, 96, 0.3);
}

/* PAGE HEADER */
.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.filter-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.7rem 1.5rem;
    background: var(--secondary);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* COUNTRIES GRID */
.countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.country-card {
    background: linear-gradient(135deg, rgba(22, 33, 62, 0.8), rgba(26, 26, 46, 0.8));
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
}

.country-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(233, 69, 96, 0.3);
    transform: translateY(-5px);
}

.country-flag {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.country-card h3 {
    color: var(--accent-light);
    margin-bottom: 0.5rem;
}

.country-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* RANKINGS TABLE */
.rankings-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(22, 33, 62, 0.5);
    border-radius: 8px;
    overflow: hidden;
}

.rankings-table thead {
    background: var(--secondary);
    border-bottom: 2px solid var(--accent);
}

.rankings-table th {
    padding: 1rem;
    text-align: left;
    color: var(--accent);
    font-weight: bold;
    text-transform: uppercase;
}

.rankings-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.rankings-table tbody tr:hover {
    background: rgba(233, 69, 96, 0.1);
}

.rankings-table tbody tr:last-child td {
    border-bottom: none;
}

.rank-badge {
    font-weight: bold;
    color: var(--accent);
}

/* MARKET */
.market-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* POPULATION */
.population-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.25rem;
    align-items: start;
}

.population-sidebar {
    background: rgba(22, 33, 62, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.population-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.population-sidebar-header h3 {
    color: var(--accent-light);
    font-size: 1rem;
}

.population-side-actions {
    display: flex;
    gap: 0.5rem;
}

.population-side-actions .filter-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

.population-country-list {
    max-height: 460px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.population-country-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    transition: background 0.2s ease;
}

.population-country-item:hover {
    background: rgba(233, 69, 96, 0.1);
}

.population-country-item input {
    accent-color: var(--accent);
}

.population-main {
    min-width: 0;
}

/* PARTIES */
.parties-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.25rem;
    align-items: start;
}

.parties-sidebar {
    background: rgba(22, 33, 62, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.parties-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.parties-sidebar-header h3 {
    color: var(--accent-light);
    font-size: 1rem;
}

.parties-main {
    min-width: 0;
}

.population-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: end;
}

.population-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.population-control label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.population-control-action {
    justify-content: end;
}

.population-chart-wrap {
    height: 460px;
    background: rgba(22, 33, 62, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

@media (max-width: 1024px) {
    .market-grid {
        grid-template-columns: 1fr;
    }

    .population-layout {
        grid-template-columns: 1fr;
    }

    .parties-layout {
        grid-template-columns: 1fr;
    }

    .population-controls {
        grid-template-columns: 1fr;
    }
}

.market-section {
    background: rgba(22, 33, 62, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.market-section h3 {
    color: var(--accent-light);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.prices-list,
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.item-price,
.order-item {
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.05), rgba(243, 156, 18, 0.05));
    padding: 1rem;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
    cursor: pointer;
    transition: all 0.3s ease;
}

.item-price:hover,
.order-item:hover {
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.15), rgba(243, 156, 18, 0.15));
}

.item-name {
    font-weight: bold;
    color: var(--accent-light);
    margin-bottom: 0.5rem;
}

.item-price-val {
    color: var(--text);
    font-size: 1.2rem;
}

/* BATTLES */
.battles-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.battle-card {
    background: linear-gradient(135deg, rgba(22, 33, 62, 0.8), rgba(26, 26, 46, 0.8));
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.battle-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(233, 69, 96, 0.3);
}

.battle-nations {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.battle-nation {
    text-align: center;
}

.battle-nation-name {
    color: var(--accent-light);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.vs-text {
    color: var(--text-muted);
    font-weight: bold;
}

.battle-info {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* SEARCH */
.search-box {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.search-input {
    flex-grow: 1;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--secondary);
    color: var(--text);
    font-size: 1rem;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

.search-btn {
    padding: 1rem 2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.search-btn:hover {
    background: var(--accent-light);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.3);
}

.search-results {
    margin-top: 2rem;
}

.search-result-item {
    background: rgba(22, 33, 62, 0.5);
    border-left: 3px solid var(--accent);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.search-result-item:hover {
    background: rgba(22, 33, 62, 0.7);
}

/* ARTICLES */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.article-card {
    background: linear-gradient(135deg, rgba(22, 33, 62, 0.8), rgba(26, 26, 46, 0.8));
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.3s ease;
}

.article-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(233, 69, 96, 0.3);
    transform: translateY(-5px);
}

.article-title {
    color: var(--accent-light);
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.article-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.article-excerpt {
    color: var(--text);
    font-size: 0.95rem;
    flex-grow: 1;
    line-height: 1.5;
}

/* LOADING */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
        padding: 0.75rem 1rem;
    }

    .nav-top {
        justify-content: space-between;
        width: 100%;
    }

    .nav-brand h1 {
        font-size: 1.2rem;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .nav-mobile-panel {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding-top: 0.25rem;
    }

    .navbar.mobile-open .nav-mobile-panel {
        display: flex;
    }

    .nav-links {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .nav-links a {
        width: 100%;
        text-align: center;
    }

    .api-status {
        justify-content: center;
        width: 100%;
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .donate-btn {
        width: 100%;
    }

    .donate-wrap {
        width: 100%;
    }

    .donate-info-popover {
        right: auto;
        left: 0;
        width: 100%;
    }

    .hero h2 {
        font-size: 1.8rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .filter-buttons {
        flex-direction: column;
    }

    .filter-btn {
        width: 100%;
    }

    .search-box {
        flex-direction: column;
    }
}
