/* === Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #000011;
    --bg-card: #0a0a1a;
    --bg-code: #181E22;
    --text: #d0d0d0;
    --text-muted: #888;
    --link: #BAD7FF;
    --link-visited: #F6BAFF;
    --accent: #4a9eff;
    --border: #222;
    --success: #4caf50;
    --error: #f44336;
    --warning: #ff9800;
    --radius: 6px;
    --max-w: 52em;
}

html { font-size: 16px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Courier New', Courier, monospace;
    line-height: 1.7;
    min-height: 100vh;
}

.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

@media (min-width: 900px) {
    .container { padding: 2rem 0.5rem; }
}

a { color: var(--link); text-decoration: none; transition: opacity 0.2s; }
a:visited { color: var(--link-visited); }
a:hover { opacity: 0.8; text-decoration: underline; }

/* === Navigation === */
.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-links { display: flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.nav-links a { padding: 0.25rem 0.5rem; border-radius: var(--radius); color: var(--link); }
.nav-links a:visited { color: var(--link); }
.nav-links a.active { background: var(--bg-code); color: var(--accent); }
.nav-links a.active:visited { color: var(--accent); }
.nav-links .sep { color: var(--text-muted); font-size: 0.8rem; }

/* === Form centering === */
.form-center { text-align: center; margin: 1rem 0; }

/* === CAPTCHA Modal === */
.captcha-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.captcha-overlay.show { display: flex; }
.captcha-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    max-width: 340px;
}
.captcha-box p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.captcha-box .captcha-widget { display: inline-block; }

/* === Transparency === */
body.page-transparency .container,
body.page-stats .container {
    max-width: 72em;
}

.transparency-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
}
.transparency-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}
.transparency-table th,
.transparency-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.9rem;
}
.transparency-table th {
    color: var(--accent);
    background: var(--bg-code);
    font-size: 0.8rem;
    text-transform: uppercase;
}
.transparency-table tr:hover td {
    background: rgba(74, 158, 255, 0.05);
}

.trans-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.trans-sortable:hover {
    color: #fff;
}

.trans-sort-icon {
    font-size: 0.75rem;
    opacity: 0.5;
    margin-left: 0.25rem;
}

.trans-sortable:hover .trans-sort-icon {
    opacity: 1;
}

.trans-sort-icon.active {
    opacity: 1;
    color: var(--accent);
}

.trans-sort-priority {
    font-size: 0.55rem;
    color: var(--accent);
    font-weight: bold;
    margin-left: 1px;
    vertical-align: super;
}

.trans-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.85rem;
}

.trans-pagination button {
    background: var(--bg-code);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.trans-pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.trans-pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.trans-pagination span { color: var(--text-muted); }

.transparency-summary p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.inline-select {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
}

/* === Typography === */
h1 { font-size: 1.6rem; color: var(--accent); margin-bottom: 0.5rem; }
h2 { font-size: 1.3rem; color: var(--link); margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.1rem; color: var(--text); margin: 1.2rem 0 0.5rem; }
p { margin-bottom: 0.75rem; }

/* === Code blocks === */
.code-block {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    overflow-x: auto;
    word-break: break-all;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.35rem;
    line-height: 1;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.code-block .label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.code-block code {
    color: var(--accent);
    display: block;
}

/* === Lists === */
ul.feature-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0;
}

ul.feature-list li {
    padding: 0.4rem 0;
    padding-left: 1.5rem;
    position: relative;
}

ul.feature-list li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: bold;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1rem 0;
}

.card-title {
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* === FAQ === */
.faq-item { margin: 1rem 0; }
.faq-q {
    color: var(--link);
    font-weight: bold;
    cursor: pointer;
    padding: 0.5rem 0;
}
.faq-q::before { content: '? '; color: var(--accent); }
.faq-a { color: var(--text-muted); padding-left: 1rem; margin-top: 0.25rem; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    color: var(--text);
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group .error-msg {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 0.2rem;
    display: none;
}

.form-group.has-error input,
.form-group.has-error textarea { border-color: var(--error); }
.form-group.has-error .error-msg { display: block; }

.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

/* === Alerts === */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    display: none;
}
.alert.show { display: block; }
.alert-success { background: rgba(76, 175, 80, 0.15); border: 1px solid var(--success); color: var(--success); }
.alert-error { background: rgba(244, 67, 54, 0.15); border: 1px solid var(--error); color: var(--error); }

/* === Status result === */
.status-result {
    margin: 1rem 0;
}

.status-result table {
    width: 100%;
    border-collapse: collapse;
}

.status-result td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.status-result td:first-child {
    color: var(--text-muted);
    white-space: nowrap;
    width: 40%;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: bold;
}
.status-badge.pending { background: rgba(255, 152, 0, 0.2); color: var(--warning); }
.status-badge.checked { background: rgba(76, 175, 80, 0.2); color: var(--success); }
.status-badge.blocked { background: rgba(244, 67, 54, 0.2); color: var(--error); }
.status-badge.archived { background: rgba(136, 136, 136, 0.2); color: #aaa; }

/* === Donate === */
.donate-addr {
    background: var(--bg-code);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    word-break: break-all;
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
}
.donate-link {
    color: var(--accent);
    word-break: break-all;
    font-size: 0.85rem;
}

/* === ToS list === */
ol.tos-list {
    padding-left: 1.5rem;
    counter-reset: tos;
}
ol.tos-list li {
    margin: 0.75rem 0;
    padding-left: 0.5rem;
}

/* === Footer === */
footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}
footer p { margin: 0.25rem 0; }

/* === Responsive === */
@media (max-width: 600px) {
    .container { padding: 1rem; }
    h1 { font-size: 1.3rem; }
    .main-nav { flex-direction: column; align-items: flex-start; }
    .lang-switch { margin-top: 0.5rem; }
}

/* === Contact CTA === */
.contact-report-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: 0.5rem 0;
}

.report-link {
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
    transition: text-shadow 0.2s;
    text-decoration: none;
    margin-top: 0.4rem;
}

.report-link:hover {
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.5);
    text-decoration: none;
    opacity: 1;
}

.report-link:visited {
    color: var(--accent);
}

.contact-disclaimer {
    color: var(--text-muted);
    font-size: 0.59rem;
    margin-top: 0.75rem;
    line-height: 1.6;
}

.contact-disclaimer a {
    font-size: 0.59rem;
}

/* === Footer === */
.footer-brand {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
}

.footer-brand:hover {
    text-decoration: underline;
    opacity: 1;
}

.footer-brand:visited {
    color: var(--accent);
}

.footer-link {
    color: #4879b1;
    text-decoration: none;
}

.footer-link:hover {
    color: #5a8fc8;
    text-decoration: underline;
    opacity: 1;
}

.footer-link:visited {
    color: #4879b1;
}

.footer-link svg {
    vertical-align: -2px;
    margin-right: 2px;
}

/* === Utility === */
.d-hidden {
    display: none;
}

.pos-relative {
    position: relative;
}

/* === Form hints === */
.form-hint {
    color: var(--text-muted);
    font-weight: normal;
}

/* === Status page === */
.status-hash-cell {
    word-break: break-all;
    font-family: monospace;
    font-size: 0.85rem;
}

.status-magnet-cell {
    word-break: break-all;
    font-size: 0.8rem;
}

.status-guide {
    margin-top: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.status-guide-title {
    margin-bottom: 0.4rem;
    color: var(--text);
}

.status-badge-sm {
    font-size: 0.75rem;
}


.appeal-section {
    margin-top: 1.5rem;
}

.appeal-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-link {
    color: var(--link);
}

/* === Transparency === */
.transparency-loading {
    text-align: center;
    padding: 2rem;
    color: #aaa;
}

.transparency-empty {
    text-align: center;
    color: #aaa;
}

/* Mobile-first: 2 evenly-distributed columns that hug both edges of the card. */
.trans-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1.2rem;
}

.trans-stats > div {
    width: calc(50% - 0.6rem);
    box-sizing: border-box;
}

/* Desktop: collapse back to a single row of naturally-sized columns. */
@media (min-width: 768px) {
    .trans-stats {
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    .trans-stats > div {
        width: auto;
    }
}

.trans-stat-accent strong { color: var(--accent); }
.trans-stat-text strong { color: var(--text); }
.trans-stat-success strong { color: var(--success); }
.trans-stat-error strong { color: var(--error); }
.trans-stat-warning strong { color: var(--warning); }

/* === Code block label spacing === */
.code-block .label-top {
    margin-top: 0.5rem;
}

/* === Home page announce hidden === */
.announce-hidden {
    display: none;
}

/* === Block check section heading === */
.section-heading-spaced {
    margin-top: 2.5rem;
}

/* === Unsubscribe === */
.unsub-msg {
    text-align: center;
    padding: 2rem 0;
}
.unsub-page {
    max-width: 560px;
    margin: 0 auto;
}
.unsub-desc {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}
.unsub-prefs {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.unsub-pref-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--border);
}
.unsub-pref-item:last-child {
    border-bottom: none;
}
.unsub-pref-master {
    background: rgba(74, 158, 255, 0.05);
}
.unsub-pref-divider {
    height: 2px;
    background: var(--border);
}
.unsub-pref-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.unsub-pref-label {
    font-weight: 500;
    font-size: 0.9rem;
}
.unsub-pref-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #333;
    border-radius: 24px;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #888;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider {
    background: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

/* === Custom scrollbar === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}
::-webkit-scrollbar-corner {
    background: var(--bg);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #333 var(--bg);
}

/* === Tracker Telemetry Dashboard === */
.stats-page-container {
    animation: fadeIn 0.4s ease;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.stats-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
    max-width: 32rem;
}

/* Pulsing Status Badges & Beacons */
.stats-live-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(76, 175, 80, 0.08);
    border: 1px solid rgba(76, 175, 80, 0.2);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--success);
    transition: opacity 0.3s ease;
}

.stats-live-badge.syncing {
    background: rgba(74, 158, 255, 0.08);
    border: 1px solid rgba(74, 158, 255, 0.2);
    color: var(--accent);
}
.stats-live-badge.syncing .pulse-dot {
    background-color: var(--accent);
    animation: pulse-beacon-syncing 2s infinite;
}

.home-stat-beacon.syncing .pulse-dot {
    background-color: var(--accent);
    animation: pulse-beacon-syncing 2s infinite;
}

@keyframes pulse-beacon-syncing {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(74, 158, 255, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(74, 158, 255, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(74, 158, 255, 0);
    }
}

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    animation: pulse-beacon 2s infinite;
}

@keyframes pulse-beacon {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* Loader Graphic & Keyframes */
.stats-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 2rem;
}

.loader-graphic {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: rotate-cw 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring-inner {
    position: absolute;
    inset: 10px;
    border: 3px solid transparent;
    border-bottom-color: var(--link-visited);
    border-radius: 50%;
    animation: rotate-ccw 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.loader-core {
    position: absolute;
    inset: 24px;
    background: rgba(74, 158, 255, 0.1);
    border: 1.5px dashed rgba(74, 158, 255, 0.3);
    border-radius: 50%;
    animation: pulse-glow 2s ease-in-out infinite;
}

.loader-text-wrap h3 {
    font-size: 1.15rem;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.loader-text-wrap p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

@keyframes rotate-cw {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes rotate-ccw {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(0.9); opacity: 0.5; box-shadow: 0 0 0 0 rgba(74, 158, 255, 0); }
    50% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 15px 2px rgba(74, 158, 255, 0.2); }
}

/* Skeletons */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 52rem;
    margin-top: 2rem;
}

.skeleton-card {
    height: 100px;
    background: linear-gradient(90deg, var(--bg-card) 25%, #141430 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    animation: pulse-skeleton 1.5s infinite;
}

@keyframes pulse-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Main Dashboard Elements */
.stats-dashboard-content {
    animation: fadeIn 0.5s ease-out;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
}

.metric-card .metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    flex-shrink: 0;
}

.metric-card .metric-info {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.6rem;
    line-height: 1.2;
    margin: 0.15rem 0;
    font-weight: bold;
}

.metric-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Glow Variants for cards */
.card-glow-accent:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px -5px rgba(74, 158, 255, 0.15);
}
.card-glow-accent .accent-icon {
    color: var(--accent);
    background: rgba(74, 158, 255, 0.08);
}

.card-glow-success:hover {
    border-color: var(--success);
    box-shadow: 0 4px 20px -5px rgba(76, 175, 80, 0.15);
}
.card-glow-success .success-icon {
    color: var(--success);
    background: rgba(76, 175, 80, 0.08);
}

.card-glow-warning:hover {
    border-color: var(--warning);
    box-shadow: 0 4px 20px -5px rgba(255, 152, 0, 0.15);
}
.card-glow-warning .warning-icon {
    color: var(--warning);
    background: rgba(255, 152, 0, 0.08);
}

.card-glow-link:hover {
    border-color: var(--link);
    box-shadow: 0 4px 20px -5px rgba(186, 215, 255, 0.15);
}
.card-glow-link .link-icon {
    color: var(--link);
    background: rgba(186, 215, 255, 0.08);
}

/* Table detail lists */
.dashboard-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.dashboard-row .card {
    margin: 0;
    min-width: 280px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table td:first-child {
    color: var(--text-muted);
    width: 35%;
}

.text-white {
    color: #fff !important;
}

/* Countdown refresh indicators */
.countdown-bar-wrap {
    width: 100%;
    height: 4px;
    background: #111;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.25rem;
    position: relative;
}

.countdown-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--accent);
    width: 0%;
    transition: width 0.1s linear;
}

.countdown-bar.syncing {
    width: 100% !important;
    background: var(--accent) !important;
    animation: pulse-countdown-syncing 1.5s ease-in-out infinite;
}

@keyframes pulse-countdown-syncing {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Swarm Distributions visual charts */
.swarm-bar-chart {
    margin-bottom: 1.5rem;
}

.swarm-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.swarm-bar-labels strong {
    font-family: monospace;
}

.swarm-bar-visual {
    height: 10px;
    background: #111;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
}

.bar-segment {
    height: 100%;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-udp {
    background: var(--accent);
    box-shadow: 0 0 10px rgba(186, 215, 255, 0.2);
}

.bar-tcp {
    background: var(--accent);
    box-shadow: 0 0 10px rgba(74, 158, 255, 0.2);
}

/* Sockets sub breakdowns */
.protocol-splits {
    display: flex;
    gap: 1.5rem;
}

.split-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.protocol-title {
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.2rem;
    margin-bottom: 0.2rem;
}

.split-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
}

.split-item span:first-child {
    color: var(--text-muted);
}

/* Heatmap for Swarm activity */
.renew-heatmap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 4px;
    margin: 1rem 0;
}

.heat-block {
    aspect-ratio: 1.6 / 1;
    background: #06060c;
    border: 1px solid #111;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: monospace;
    font-size: 0.65rem;
    color: #444;
    transition: all 0.3s;
    cursor: default;
    position: relative;
}

.heat-block:hover {
    transform: scale(1.08);
    z-index: 10;
    border-color: #333;
}

/* Tooltip on heat-block */
.heat-block::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    border: 1px solid var(--border);
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.heat-block:hover::after {
    opacity: 1;
    transform: translate(-50%, -4px);
}

.heat-block.level-0 { background: #06060e; color: #444; }
.heat-block.level-1 { background: rgba(74, 158, 255, 0.15); border-color: rgba(74, 158, 255, 0.2); color: #7cb3f2; }
.heat-block.level-2 { background: rgba(74, 158, 255, 0.35); border-color: rgba(74, 158, 255, 0.4); color: #b1d4fc; }
.heat-block.level-3 { background: rgba(74, 158, 255, 0.6); border-color: rgba(74, 158, 255, 0.7); color: #fff; text-shadow: 0 0 5px rgba(74, 158, 255, 0.4); }
.heat-block.level-4 { background: var(--accent); border-color: #fff; color: #000; font-weight: bold; }

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-scale {
    display: flex;
    gap: 3px;
}

.legend-scale span {
    width: 14px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid #111;
}
.legend-scale .level-0 { background: #06060e; }
.legend-scale .level-1 { background: rgba(74, 158, 255, 0.15); }
.legend-scale .level-2 { background: rgba(74, 158, 255, 0.35); }
.legend-scale .level-3 { background: rgba(74, 158, 255, 0.6); }
.legend-scale .level-4 { background: var(--accent); }

/* === Home stats widget (Horizontal bar) === */
.home-stats-widget {
    margin: 1.5rem 0 2rem;
    padding: 0.85rem 1.25rem;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    animation: fadeIn 0.4s ease;
}

.home-stats-skeleton {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.home-stats-skeleton .pulse-dot {
    background-color: var(--accent);
    animation: pulse-beacon 1.5s infinite;
}

.home-stats-content {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.home-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.home-stat-item .h-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.home-stat-item .h-value {
    font-size: 1.05rem;
}

.home-stat-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}

.home-stat-beacon {
    position: absolute;
    top: 6px;
    right: 8px;
}

.home-stat-beacon .pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
}

/* General Layout helpers & Animations */
.stats-error-container {
    text-align: center;
    padding: 3rem 1.5rem;
    max-width: 420px;
    margin: 0 auto;
}

.stats-error-container h3 {
    margin: 1rem 0 0.5rem;
    color: var(--error);
}

.stats-error-container p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

.font-mono {
    font-family: monospace;
}

.flex-1 {
    flex: 1;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .dashboard-row {
        flex-direction: column;
    }
    /* Without this override the 280px floor on dashboard-row cards forces horizontal scroll
       on viewports narrower than ~330px (280px card + 48px container padding). That's what
       was making the page look "squeezed to the left" — the browser was just showing the
       left side of an over-wide layout. */
    .dashboard-row .card {
        min-width: 0;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .home-stat-divider {
        display: none;
    }
    .home-stats-content {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: space-between;
        align-items: center;
    }
    /* On mobile, force each stat item to roughly half-width so we get a clean 2-column grid
       with the items snapping to both edges (left/right) instead of leaving a ragged gap. */
    .home-stats-content .home-stat-item {
        flex: 1 1 calc(50% - 0.4rem);
        min-width: 0;
    }
    /* Home widget gets a tighter padding so it doesn't grow taller after switching from
       grid to flex. */
    .home-stats-widget {
        padding: 0.7rem 0.85rem;
    }
    /* Stats page header: switch to flex column so the h1, subtitle, and live badge all
       center horizontally. The earlier text-align: center didn't work because the header
       was still flex-row with wrap — items each got their own line but aligned to the
       cross axis (top in row mode). */
    .stats-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    /* Subtitle had a max-width: 32rem which broke centering on narrow screens — let it
       stretch and rely on the parent's text-align for visual alignment. */
    .stats-subtitle {
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    /* Heatmap tooltip on edge cells was overflowing the viewport. Cap it. */
    .heat-block::after {
        max-width: 90vw;
        white-space: normal;
    }
    /* Smaller padding on stats table rows so the System Status panel doesn't dominate the
       fold on a phone. */
    .stats-table td {
        padding: 0.4rem 0.5rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    /* On phones the icon + text reads better side-by-side than stacked: the old column layout
       wasted vertical space and made the numbers feel disconnected from their icons. */
    .metric-card {
        padding: 0.85rem;
        gap: 0.75rem;
    }
    .metric-card .metric-icon {
        width: 36px;
        height: 36px;
        border-radius: 6px;
    }
    .metric-card .metric-info {
        flex: 1;
        min-width: 0;
    }
    .metric-value {
        font-size: 1.3rem;
    }
    .metric-label,
    .metric-sub {
        font-size: 0.7rem;
    }
    .protocol-splits {
        flex-direction: column;
        gap: 1.25rem;
    }
    /* When UDP/TCP columns stack, the title runs into the rows. A bottom border restores
       visual separation. */
    .protocol-title {
        display: block;
        border-bottom: 1px solid var(--border);
        padding-bottom: 0.4rem;
        margin-bottom: 0.4rem;
    }
    /* Heatmap blocks shrink so we get an extra column or two on 360px viewports. */
    .renew-heatmap {
        grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
        gap: 3px;
    }
    .heat-block {
        font-size: 0.6rem;
    }
}

