:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --bg-deep: #000C17;
    --bg-card: rgba(0, 25, 48, 0.8);
    --bg-surface: rgba(0, 12, 23, 0.95);
    --border-subtle: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --link-color: #3498db;
    --link-hover: #5dade2;
    --gradient-header: linear-gradient(135deg, #001930, #002a4a);
}

* { box-sizing: border-box; }

html {
    background-color: var(--bg-deep);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-deep) 0%, #001930 100%);
    min-height: 100vh;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

.main-container {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    margin: 20px auto;
    padding: 30px;
    max-width: 1400px;
    border: 1px solid var(--border-subtle);
}

/* Top bar (header + search combined) */
.top-bar {
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-deep);
    margin: 0 -30px 20px;
    padding: 12px 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    gap: 24px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    padding: 8px 0;
    flex-shrink: 0;
}

.header img {
    height: 80px;
    margin-right: 16px;
    transition: height 0.3s ease;
}

.header-content { flex: 1; white-space: nowrap; }
.header-content h1 { margin: 0; font-size: 2.2em; transition: font-size 0.3s ease; }
.header-content h2 { margin: 5px 0 0; font-weight: 400; color: var(--text-secondary); font-size: 1.1em; transition: all 0.3s ease; }

/* Scrolled state — shrink header to search bar height */
.top-bar.scrolled .header img { height: 32px; margin-right: 10px; }
.top-bar.scrolled .header-content h1 { font-size: 1.2em; }
.top-bar.scrolled .header-content h2 { font-size: 0; margin: 0; opacity: 0; }

/* Stats cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--secondary-color);
    transition: transform 0.2s ease;
}

.stat-card:hover { transform: translateY(-2px); }
.stat-card .stat-value { font-size: 1.8em; font-weight: 700; margin: 0; }
.stat-card .stat-label { color: var(--text-secondary); font-size: 0.85em; margin: 4px 0 0; }

/* Timeframe selector card */
.stat-card.stat-card--selectable { cursor: pointer; position: relative; user-select: none; }
.stat-card.stat-card--selectable:hover { border-color: var(--secondary-color); }
.stat-card--selectable .stat-label .chevron {
    font-size: 0.7em;
    margin-left: 4px;
    opacity: 0.6;
    transition: transform 0.2s ease;
}
.stat-card--selectable.open .stat-label .chevron { transform: rotate(180deg); }
.stat-card--selectable .timeframe-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
    z-index: 100;
    min-width: 140px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.stat-card--selectable.open .timeframe-dropdown { display: block; }
.timeframe-dropdown button {
    display: block;
    width: 100%;
    padding: 9px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85em;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.timeframe-dropdown button:hover { background: rgba(52, 152, 219, 0.15); color: var(--text-primary); }
.timeframe-dropdown button.active {
    color: var(--secondary-color);
    font-weight: 600;
    background: rgba(52, 152, 219, 0.08);
}

/* Universal search */
.search-bar {
    flex: 1;
    min-width: 0;
}

.search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 0 0 auto;
}

.search-input {
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 25px;
    padding: 12px 20px 12px 44px;
    width: 100%;
    transition: all 0.3s ease;
    background: var(--bg-card);
    color: white;
    font-size: 15px;
    outline: none;
}

.search-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.25);
    background: rgba(0,25,48,1);
}

.search-input::placeholder { color: var(--text-muted); }

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #001930;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin-top: 4px;
}

.search-results.active { display: block; }

.search-results-section { padding: 8px 0; }
.search-results-section + .search-results-section { border-top: 1px solid var(--border-subtle); }

.search-results-title {
    padding: 6px 16px;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.search-result-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-item:hover { background: rgba(52,152,219,0.15); }
.search-result-item .result-name { font-weight: 500; }
.search-result-item .result-meta { color: var(--text-muted); font-size: 0.85em; }

/* Expandable sections */
.expandable-section {
    background: var(--bg-card);
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.section-header {
    background: var(--gradient-header);
    color: white;
    padding: 18px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
    border-bottom: 1px solid var(--border-subtle);
    user-select: none;
}

.section-header:hover { background: linear-gradient(135deg, var(--secondary-color), #2980b9); }
.section-header h3 { margin: 0; font-size: 1.1em; }

.section-content { padding: 20px; display: none; }
.section-content.active { display: block; }

/* Tables */
.modern-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border: 1px solid var(--border-subtle);
}

.modern-table th {
    background: var(--gradient-header);
    color: white;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.modern-table th:hover { background: linear-gradient(135deg, #002a4a, #003d6b); }
.modern-table th .sort-arrow { margin-left: 6px; font-size: 0.75em; color: var(--text-muted); }
.modern-table th .sort-arrow.active { color: var(--secondary-color); }

.modern-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s;
    color: white;
}

.modern-table tr:hover td { background: rgba(52,152,219,0.08); }
.modern-table tbody tr:nth-child(odd) td { background-color: rgba(0,25,48,0.5); }
.modern-table tbody tr:nth-child(odd):hover td { background: rgba(52,152,219,0.12); }

.status-dot {
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.status-dot.online { background: var(--success-color); box-shadow: 0 0 6px var(--success-color); }
.status-dot.issue { background: var(--warning-color); box-shadow: 0 0 6px var(--warning-color); }
.status-dot.offline { background: var(--danger-color); box-shadow: 0 0 6px var(--danger-color); }

/* Screenshot icon column */
.screenshot-icon {
    color: var(--text-muted);
    font-size: 0.8em;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.screenshot-icon:hover {
    color: var(--secondary-color);
    transform: scale(1.2);
}

.post-icon-col {
    width: 20px;
    flex-shrink: 0;
    text-align: center;
}

.icon-col {
    width: 30px;
    text-align: center;
}

/* Links */
.group-link {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.group-link:hover { color: var(--link-hover); text-decoration: underline; }

.back-link {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 20px;
    display: inline-block;
    transition: color 0.2s;
}

.back-link:hover { color: var(--link-hover); text-decoration: underline; }

/* Posts */
.post-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s, padding-left 0.15s;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}

.post-item:last-child { border-bottom: none; }
.post-item:hover { background: rgba(52,152,219,0.08); padding-left: 24px; }

.post-title {
    font-weight: 500;
    cursor: default;
    flex: 1;
    min-width: 200px;
}


.post-group { min-width: 120px; }

.post-date { color: var(--text-secondary); font-size: 0.9em; white-space: nowrap; }

.post-url {
    font-size: 0.8em;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    word-break: break-all;
    width: 100%;
}

/* Pagination */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 4px 4px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 8px;
}

.pagination-info { color: var(--text-muted); font-size: 0.85em; }

.pagination-nav { display: flex; gap: 8px; }

.pagination-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--secondary-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
    outline: none;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--secondary-color);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* Screenshot popup */
.screenshot-popup {
    position: fixed;
    z-index: 1000;
    background: #001930;
    border: 2px solid var(--secondary-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    padding: 8px;
    max-width: 600px;
    max-height: 80vh;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    overflow: hidden;
}

.screenshot-popup.visible { opacity: 1; }

.screenshot-popup img {
    max-width: 100%;
    max-height: calc(80vh - 16px);
    display: block;
    border-radius: 8px;
}

/* Filter buttons */
.filter-container { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.filter-btn {
    padding: 6px 16px;
    border: 2px solid var(--secondary-color);
    background: var(--bg-card);
    color: var(--secondary-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    outline: none;
}

.filter-btn.active { background: var(--secondary-color); color: white; }
.filter-btn:hover { background: var(--secondary-color); color: white; }

/* Scrape health */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.health-item {
    background: rgba(0,25,48,0.6);
    border-radius: 10px;
    padding: 14px;
    border: 1px solid var(--border-subtle);
}

.health-item .label { color: var(--text-muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.5px; }
.health-item .value { font-size: 1.3em; font-weight: 600; margin-top: 4px; }

.health-alerts { margin-top: 12px; }

.health-alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.health-alert.warning { background: rgba(243,156,18,0.15); border-left: 3px solid var(--warning-color); }
.health-alert.danger { background: rgba(231,76,60,0.15); border-left: 3px solid var(--danger-color); }
.health-alert.info { background: rgba(52,152,219,0.15); border-left: 3px solid var(--secondary-color); }

/* Group detail */
.group-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

.group-header h1 { margin: 0; font-size: 2em; }

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

.location-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.location-item:last-child { border-bottom: none; }
.location-item code { color: var(--text-secondary); font-size: 0.9em; word-break: break-all; min-width: 0; }

/* Contact section */
.contact-section {
    background: var(--bg-card);
    border-radius: 15px;
    padding: 20px;
    margin-top: 30px;
    margin-bottom: 30px;
    border: 1px solid var(--border-subtle);
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.contact-links {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--link-color);
    text-decoration: none;
    padding: 10px 15px;
    border-radius: 10px;
    background: rgba(52,152,219,0.1);
    border: 1px solid rgba(52,152,219,0.3);
    transition: all 0.2s;
    font-weight: 500;
}

.contact-link:hover {
    background: rgba(52,152,219,0.2);
    color: var(--link-hover);
    transform: translateY(-2px);
    text-decoration: none;
}

.contact-link i { font-size: 1.2em; }

/* Footer */
.site-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85em;
    max-width: 1400px;
    margin: 0 auto;
}

.site-footer a { color: var(--link-color); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

.support-btn-wrapper {
    margin-bottom: 20px;
}

.support-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    padding: 10px 22px;
    border-radius: 30px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95em;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.support-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    text-decoration: none;
}

.support-button i {
    color: #ff4d4d;
    filter: drop-shadow(0 0 5px rgba(255, 77, 77, 0.4));
    font-size: 1.1em;
}

/* API docs */
.api-section { margin-bottom: 30px; }
.api-section p { color: var(--text-secondary); line-height: 1.7; }

.api-endpoint {
    background: rgba(0,25,48,0.6);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-subtle);
}

.api-endpoint h4 { margin: 0 0 8px; }
.api-endpoint h4 code { color: var(--secondary-color); font-size: 1.1em; }
.api-endpoint p { margin: 0 0 12px; color: var(--text-secondary); }

.api-endpoint pre {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 0;
}

.api-endpoint pre code { color: var(--text-secondary); font-size: 0.85em; }

.section-title {
    color: var(--secondary-color);
    margin-bottom: 16px;
    font-size: 1.3em;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .main-container { margin: 10px; padding: 16px; border-radius: 12px; }
    .top-bar {
        display: block;
        margin: 0 -16px;
        padding: 0 16px;
        gap: 0;
    }
    .top-bar.scrolled .header {
        max-height: 0;
        overflow: hidden;
        padding: 0;
        margin: 0;
        opacity: 0;
    }
    .header {
        flex-direction: column;
        text-align: center;
        padding: 10px;
        margin-bottom: 12px;
        max-height: 200px;
        opacity: 1;
        transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease, margin 0.3s ease;
    }
    .header img { margin: 0 0 12px; height: 70px; }
    .search-bar { padding: 12px 0; }
    .search-wrapper { margin: 0 auto; }
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 1.4em; }
    .modern-table { font-size: 14px; }
    .modern-table th, .modern-table td { padding: 8px 10px; }
    .post-item { padding: 10px 12px; }
    .post-title { min-width: 140px; }
    .contact-links { flex-direction: column; align-items: center; }
    .contact-link { width: 100%; max-width: 300px; justify-content: center; }
    .search-input { font-size: 14px; padding: 10px 16px 10px 40px; }
    .screenshot-popup { max-width: 90vw; }
    .group-header h1 { font-size: 1.5em; }
}

@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr 1fr; }
    .health-grid { grid-template-columns: 1fr; }
}
