:root {
    --bg-primary: #1a1b1e;
    --bg-secondary: #27282b;
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --accent-primary: #3f83f8;
    --accent-secondary: #1a56db;
    --success: #31c48d;
    --warning: #f6ad55;
    --error: #f98080;
    --info: #60a5fa;
}

html,
body {
    height: 100%;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

.header-bar {
    background-color: var(--bg-secondary);
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 2rem;
}

.nav-link {
    color: var(--text-secondary);
    transition: color 0.2s ease;
    position: relative;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0;
    display: inline-block;
}

.nav-link:hover {
    color: var(--accent-primary);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent-primary);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

.footer {
    background-color: var(--bg-secondary);
    padding: 2rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.footer-link {
    color: var(--text-secondary);
    transition: color 0.2s ease;
    font-size: 14px !important;
}

.footer-link:hover {
    color: var(--text-primary);
}

.copyright {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px !important;
}

@media (max-width: 768px) {
    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
}

.metric-card {
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-primary);
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-container {
    background-color: var(--bg-secondary);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
    min-height: 350px;
    position: relative;
    overflow: hidden;
}

/* Special styling for per-IP analytics container */
.chart-container:has(#perIPContent) {
    height: auto;
    min-height: auto;
}

/* Special styling for Frequently Accessed Paths to keep disclaimer at bottom */
.chart-container:has(#pathContent) {
    display: flex;
    flex-direction: column;
}

.chart-container:has(#pathContent) #pathContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.chart-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    color: var(--text-primary);
}

.chart-container canvas {
    max-height: 250px !important;
    height: 250px !important;
}

.tab-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.tab-button {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1.5rem;
    margin: 0 0.25rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-button.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.tab-button:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.loading {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(63, 131, 248, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
}

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

.alert {
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-info {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(59, 130, 246, 0.1));
    border-color: var(--info);
    color: var(--info);
    border-left: 4px solid var(--info);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.1);
}

/* Infobox label styling (emoji + heading) */
.infobox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--info);
}

.infobox-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    font-size: 1rem;
    line-height: 1;
    background: rgba(96, 165, 250, 0.12);
    border-radius: 6px;
    padding: 0.15rem 0.25rem;
}

.infobox-heading {
    text-transform: none;
    color: var(--info);
}

/* Make infobox policy links more noticeable */
.infobox-link {
    color: var(--accent-primary);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(63, 131, 248, 0.18);
    text-underline-offset: 3px;
}

.infobox-link:hover {
    color: var(--accent-secondary);
    text-decoration-color: rgba(29, 78, 216, 0.25);
}

.country-list {
    list-style: none;
    padding: 0;
    margin: 0 8px;
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.6) transparent;
}

.country-list::-webkit-scrollbar {
    width: 8px;
}

.country-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.country-list::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.country-list::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.8);
}

.country-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 8px 12px 8px;
    margin-right: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 15px;
    min-height: 60px;
}

/* Path analytics styles */
.path-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
    font-style: italic;
}

.path-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 8px 12px 8px;
    margin-right: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 15px;
    min-height: 60px;
}

.path-item:last-child {
    border-bottom: none;
}

.path-name {
    font-weight: 500;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.path-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.path-requests {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.875rem;
}

.path-bytes {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.country-item:last-child {
    border-bottom: none;
}

.country-name {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.country-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 120px;
    flex-shrink: 0;
}

.country-requests {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.9rem;
}

.country-bytes {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.country-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    flex: 0 0 100px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.country-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.country-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.http-version-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
    font-style: italic;
}

.country-error {
    text-align: center;
    padding: 40px;
    color: var(--error);
    background: rgba(249, 128, 128, 0.1);
    border-radius: 6px;
    margin: 10px 0;
}

/* Per-IP Analytics Styles */
.privacy-disclaimer {
    background: rgba(96, 165, 250, 0.08);
    border-left: 3px solid rgba(96, 165, 250, 0.4);
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.privacy-disclaimer strong {
    color: var(--info);
    font-weight: 600;
}

/* Top Users disclaimer styling to match path-disclaimer */
.topusers-disclaimer {
    background: rgba(96, 165, 250, 0.08);
    border-left: 3px solid rgba(96, 165, 250, 0.4);
    border-radius: 4px;
    padding: 12px 16px;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.topusers-disclaimer strong {
    color: var(--info);
    font-weight: 600;
}

.topusers-disclaimer p {
    margin: 0;
}

.topusers-disclaimer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.topusers-disclaimer a:hover {
    text-decoration: underline;
}

/* Path disclaimer - subtle, professional styling */
.path-disclaimer {
    background: rgba(96, 165, 250, 0.08);
    border-left: 3px solid rgba(96, 165, 250, 0.4);
    border-radius: 4px;
    padding: 12px 16px;
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.path-disclaimer p {
    margin: 0;
}

.path-disclaimer strong {
    color: var(--info);
    font-weight: 600;
}

/* Top Users styles - clean list layout matching paths/countries */
.topusers-list {
    list-style: none;
    padding: 0;
    margin: 0 8px;
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.6) transparent;
}

.topusers-list::-webkit-scrollbar {
    width: 8px;
}

.topusers-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.topusers-list::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.topusers-list::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.8);
}

.topuser-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 8px;
    margin-right: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 15px;
    min-height: 60px;
}

.topuser-item:last-child {
    border-bottom: none;
}

.topuser-info {
    flex: 1;
    min-width: 0;
}

.topuser-ip {
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 4px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topuser-details {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.inline-path {
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    font-weight: 500;
}

.topuser-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    min-width: 120px;
}

.topuser-requests {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.875rem;
}

.topuser-colos {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.colo-chip {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.colo-chip.more {
    color: var(--accent-primary);
}

/* Top Users Progress Bar Styles */
.topusers-progress {
    padding: 24px;
    background: rgba(63, 131, 248, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(63, 131, 248, 0.15);
}

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

.progress-text {
    font-weight: 500;
    color: var(--text-primary);
}

.progress-count {
    font-size: 0.875rem;
    color: var(--accent-primary);
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(63, 131, 248, 0.3);
}

.progress-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.progress-ranges {
    margin-top: 8px;
    text-align: center;
}

.progress-ranges small {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Error / empty state alignment reuse */
.topusers-empty {
    text-align: center;
    padding: 40px;
    color: var(--error);
    background: rgba(249, 128, 128, 0.06);
    border-radius: 6px;
}

/* Generic error style used across the UI to match other error blocks */
.error {
    text-align: center;
    padding: 28px 16px;
    color: var(--error);
}

.privacy-disclaimer p {
    margin: 0;
}

.privacy-disclaimer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.privacy-disclaimer a:hover {
    text-decoration: underline;
}

.perip-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.perip-summary {
    padding: 20px;
}

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

.perip-stat-full {
    grid-column: 1 / -1;
}

.perip-stats .perip-stat:nth-child(3) {
    grid-column: 1;
    grid-row: 3;
}

.perip-stats .perip-stat:nth-child(4) {
    grid-column: 2;
    grid-row: 3;
}

.perip-stats .perip-stat:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
}

@media (min-width: 768px) {
    .perip-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {

    .perip-stats .perip-stat:nth-child(4),
    .perip-stats .perip-stat:nth-child(5) {
        grid-column: 1;
        grid-row: auto;
    }

    .topuser-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .topuser-stats {
        align-items: flex-start;
        width: 100%;
    }
}

.perip-stat {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.perip-stat .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-primary);
    display: block;
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
    line-height: 1.2;
    text-align: center;
}

.perip-stat .stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    text-align: center;
}

.perip-paths h4 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 600;
}

.perip-paths-list {
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.6) transparent;
    margin: 0 8px;
}

.perip-paths-list::-webkit-scrollbar {
    width: 8px;
}

.perip-paths-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.perip-paths-list::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.perip-paths-list::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.8);
}

.perip-path-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.perip-path-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(63, 131, 248, 0.1);
}

.perip-path-info {
    margin-bottom: 12px;
}

.perip-path-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    display: block;
    margin-bottom: 4px;
}

.perip-path-details {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.perip-path-bar {
    background: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}

.perip-path-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 6px rgba(63, 131, 248, 0.4);
}

.perip-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.perip-footer small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

@media (max-width: 768px) {
    .metric-value {
        font-size: 1.5rem;
    }

    .chart-container {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .perip-stats {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }

    .perip-stat {
        padding: 15px;
    }

    .perip-stat .stat-value {
        font-size: 1.4rem;
    }

    .privacy-disclaimer {
        padding: 12px;
        font-size: 0.85rem;
        margin-bottom: 15px;
    }

    .perip-path-item {
        padding: 12px;
        margin-bottom: 10px;
    }

    .perip-path-name {
        font-size: 0.9rem;
    }

    .perip-path-details {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .chart-container {
        padding: 0.75rem;
    }

    .chart-title {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .perip-stats {
        gap: 10px;
    }

    .perip-stat {
        padding: 12px;
    }

    .perip-stat .stat-value {
        font-size: 1.2rem;
    }

    .perip-stat .stat-label {
        font-size: 0.8rem;
    }

    .privacy-disclaimer {
        padding: 10px;
        font-size: 0.8rem;
    }
}

/* HTTP Version Styles */
.http-version-summary {
    margin-bottom: 1.5rem;
}

.http-version-total {
    text-align: center;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.http-version-total-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.http-version-total-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.http-version-chart {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.http-version-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.http-version-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.http-version-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.http-version-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.http-version-name {
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

.http-version-label {
    font-weight: 600;
    color: var(--text-primary);
    flex-grow: 1;
}

.http-version-percentage {
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 0.875rem;
}

.http-version-stats {
    margin-left: 1.7rem;
}

.http-version-requests {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.http-version-bar {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-left: 1.7rem;
}

.http-version-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

@media (max-width: 768px) {
    .http-version-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .http-version-percentage {
        align-self: flex-end;
    }

    .http-version-stats,
    .http-version-bar {
        margin-left: 0;
    }
}

/* Small rank indicator styled like info icon */
.topuser-rank {
    display: inline-block;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: #ffffff;
    background: #3B82F6;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.topuser-requests {
    font-weight: 700;
}

.topuser-pct {
    font-weight: 400;
    color: #9CA3AF;
    margin-left: 6px;
}

.topuser-sample {
    font-size: 0.9em;
    color: #9CA3AF;
    margin-top: 4px;
}