/* ============================================================
   BGPv6.com — Modern Design System (Bootstrap 5.3 overrides)
   ============================================================ */

/* --- Typography --- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}
.font-mono, .fm { font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace !important; }
h1, h2, h3, h4, h5 { letter-spacing: -0.025em; }

/* --- Dark Theme Override --- */
[data-bs-theme="dark"] {
    --bs-body-bg: #0b0f19;
    --bs-body-color: #e0e6f0;
    --bs-secondary-bg: #111827;
    --bs-tertiary-bg: #161d2e;
    --bs-border-color: #1e2a3a;
    --bs-card-bg: #111827;
    --bs-emphasis-color: #f1f5f9;
    --bs-link-color: #60a5fa;
    --bs-link-hover-color: #93c5fd;
    --bs-table-bg: transparent;
    --bs-table-border-color: #1e2a3a;
    --bs-table-striped-bg: rgba(255,255,255,0.02);
    --bs-table-hover-bg: rgba(96,165,250,0.06);
}
[data-bs-theme="light"] {
    --bs-body-bg: #f8fafc;
    --bs-body-color: #1e293b;
    --bs-secondary-bg: #ffffff;
    --bs-tertiary-bg: #f1f5f9;
    --bs-border-color: #e2e8f0;
    --bs-card-bg: #ffffff;
    --bs-emphasis-color: #0f172a;
    --bs-link-color: #2563eb;
    --bs-link-hover-color: #1d4ed8;
    --bs-table-bg: transparent;
    --bs-table-border-color: #e2e8f0;
    --bs-table-striped-bg: rgba(0,0,0,0.02);
    --bs-table-hover-bg: rgba(37,99,235,0.04);
}

/* --- Accent Colors --- */
:root {
    --accent-blue: #60a5fa;
    --accent-green: #34d399;
    --accent-amber: #fbbf24;
    --accent-red: #f87171;
    --accent-purple: #a78bfa;
    --accent-cyan: #22d3ee;
}
[data-bs-theme="light"] {
    --accent-blue: #2563eb;
    --accent-green: #16a34a;
    --accent-amber: #d97706;
    --accent-red: #dc2626;
    --accent-purple: #7c3aed;
    --accent-cyan: #0891b2;
}

/* --- Page Entrance --- */
main > .container-xl { animation: pageIn 0.3s ease-out; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Custom Scrollbar (dark) --- */
[data-bs-theme="dark"] ::-webkit-scrollbar { width: 8px; height: 8px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-track { background: #0b0f19; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: #2a3548; border-radius: 4px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3b4a60; }

/* --- Focus Visible (accessibility) --- */
:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}
.btn:focus-visible, .nav-link:focus-visible, .form-control:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* --- Navbar --- */
.navbar {
    background: rgba(11, 15, 25, 0.92);
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
    box-shadow: 0 1px 0 rgba(255,255,255,0.04);
}
[data-bs-theme="light"] .navbar {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 0 #e2e8f0, 0 2px 8px rgba(0,0,0,0.04);
}
.navbar-brand-text {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
}
.navbar .nav-link {
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem !important;
    border-radius: 0.5rem;
    transition: background 0.15s, color 0.15s;
}
.navbar .nav-link:hover {
    background: rgba(255,255,255,0.06);
}
[data-bs-theme="light"] .navbar .nav-link:hover {
    background: rgba(0,0,0,0.04);
}
.navbar .nav-link.active {
    color: var(--accent-blue) !important;
    background: rgba(96,165,250,0.1);
}
[data-bs-theme="light"] .navbar .nav-link.active {
    background: rgba(37,99,235,0.08);
}
.navbar-search {
    max-width: 480px;
}
.navbar-search .form-control {
    border-radius: 0.625rem;
    padding-left: 2.5rem;
    font-size: 0.875rem;
}
.navbar-search .form-control:focus {
    box-shadow: 0 0 0 3px rgba(96,165,250,0.25);
    border-color: var(--accent-blue);
}
.navbar-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.4;
    pointer-events: none;
}
/* Keyboard shortcut hint */
.search-kbd {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6875rem;
    font-family: 'Inter', sans-serif;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    opacity: 0.4;
    pointer-events: none;
    border: 1px solid var(--bs-border-color);
    line-height: 1.4;
}
/* Navbar mobile collapse animation */
.navbar-collapse { transition: all 0.25s ease; }
@media (max-width: 991.98px) {
    .navbar-collapse {
        padding-top: 0.75rem;
        border-top: 1px solid var(--bs-border-color);
        margin-top: 0.5rem;
    }
}

/* Search Results Dropdown */
#search-results, #home-search-results, #mobile-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 420px;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    margin-top: 0.25rem;
}
[data-bs-theme="light"] #search-results,
[data-bs-theme="light"] #home-search-results,
[data-bs-theme="light"] #mobile-search-results {
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

/* --- Cards --- */
.card {
    border-radius: 0.875rem;
    border: 1px solid var(--bs-border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
[data-bs-theme="dark"] .card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.06);
}
[data-bs-theme="light"] .card {
    box-shadow: 0 1px 4px rgba(15,23,42,0.06), 0 0 0 1px rgba(15,23,42,0.03);
    border: 1px solid #e2e8f0;
}
.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.15);
    border-color: var(--accent-blue);
}
[data-bs-theme="light"] .card-hover:hover {
    box-shadow: 0 10px 24px rgba(37,99,235,0.1), 0 0 0 1px rgba(37,99,235,0.15);
    border-color: var(--accent-blue);
}

/* Card Accent Borders */
.card-accent-blue { border-top: 3px solid var(--accent-blue); }
.card-accent-green { border-top: 3px solid var(--accent-green); }
.card-accent-amber { border-top: 3px solid var(--accent-amber); }
.card-accent-red { border-top: 3px solid var(--accent-red); }
.card-accent-purple { border-top: 3px solid var(--accent-purple); }
/* Left accent variants */
.card-left-blue { border-left: 3px solid var(--accent-blue) !important; }
.card-left-green { border-left: 3px solid var(--accent-green) !important; }
.card-left-amber { border-left: 3px solid var(--accent-amber) !important; }

/* --- Stat Cards --- */
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.6;
    margin-top: 0.375rem;
}
.stat-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* --- Tables --- */
.table {
    font-size: 0.875rem;
    margin-bottom: 0;
}
.table > thead > tr > th {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom-width: 1px;
    padding: 0.875rem 1rem;
    white-space: nowrap;
    color: var(--bs-body-color);
    opacity: 0.6;
}
.table > tbody > tr > td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    white-space: nowrap;
}
.table > tbody > tr > td.wrap { white-space: normal; }
.table-hover > tbody > tr:hover {
    box-shadow: inset 3px 0 0 var(--accent-blue);
}
.table > tbody > tr {
    transition: background 0.1s;
}

/* --- Badges --- */
.badge {
    border-radius: 2rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.3em 0.7em;
}
.badge-rir-ripe    { background: rgba(96,165,250,0.15) !important; color: var(--accent-blue) !important; }
.badge-rir-arin    { background: rgba(52,211,153,0.15) !important; color: var(--accent-green) !important; }
.badge-rir-apnic   { background: rgba(251,191,36,0.15) !important; color: var(--accent-amber) !important; }
.badge-rir-lacnic  { background: rgba(167,139,250,0.15) !important; color: var(--accent-purple) !important; }
.badge-rir-afrinic { background: rgba(248,113,113,0.15) !important; color: var(--accent-red) !important; }
.badge-unknown     { background: rgba(100,116,139,0.15) !important; color: #94a3b8 !important; }
.badge-rpki-valid   { background: rgba(52,211,153,0.15) !important; color: var(--accent-green) !important; }
.badge-rpki-invalid { background: rgba(248,113,113,0.15) !important; color: var(--accent-red) !important; }
.badge-rpki-unknown { background: rgba(251,191,36,0.15) !important; color: var(--accent-amber) !important; }

/* --- Hero --- */
.hero-gradient {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-title {
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}
@media (max-width: 576px) { .hero-title { font-size: 2.75rem; } }

/* Hero Section Glow */
.hero-section { position: relative; overflow: hidden; }
.hero-section::before {
    content: '';
    position: absolute;
    top: -50%; left: -25%; width: 150%; height: 200%;
    background: radial-gradient(ellipse at 50% 0%, rgba(96,165,250,0.1) 0%, transparent 55%);
    pointer-events: none;
}
[data-bs-theme="light"] .hero-section::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(37,99,235,0.06) 0%, transparent 55%);
}

/* --- Home Search --- */
.home-search .form-control {
    font-size: 1.125rem;
    padding: 1rem 1rem 1rem 3rem;
    border-radius: 1rem;
    border-width: 2px;
}
.home-search .form-control:focus {
    box-shadow: 0 0 0 4px rgba(96,165,250,0.2);
    border-color: var(--accent-blue);
}
.home-search .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    opacity: 0.4;
}
.try-badge {
    font-size: 0.8125rem;
    padding: 0.3rem 0.875rem;
    border-radius: 2rem;
    text-decoration: none;
    transition: all 0.15s;
    font-weight: 500;
}
[data-bs-theme="dark"] .try-badge { background: rgba(255,255,255,0.06); color: #94a3b8; }
[data-bs-theme="dark"] .try-badge:hover { background: rgba(96,165,250,0.15); color: var(--accent-blue); }
[data-bs-theme="light"] .try-badge { background: rgba(0,0,0,0.05); color: #64748b; }
[data-bs-theme="light"] .try-badge:hover { background: rgba(37,99,235,0.1); color: var(--accent-blue); }

/* --- Quick Lookup --- */
.quick-card { text-decoration: none !important; color: inherit !important; }
.quick-card .card { transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
.quick-card:hover .card {
    transform: translateY(-3px);
    border-color: var(--accent-blue);
    box-shadow: 0 6px 24px rgba(96,165,250,0.14);
}
.quick-card .card-chevron {
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s ease;
    color: var(--accent-blue);
}
.quick-card:hover .card-chevron {
    opacity: 1;
    transform: translateX(0);
}

/* --- AS Path --- */
.as-path-hop {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.875rem;
    border-radius: 2rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.15s;
}
[data-bs-theme="dark"] .as-path-hop { background: rgba(255,255,255,0.06); color: var(--accent-blue); }
[data-bs-theme="dark"] .as-path-hop:hover { background: rgba(96,165,250,0.18); transform: translateY(-1px); }
[data-bs-theme="dark"] .as-path-hop.origin {
    background: rgba(52,211,153,0.15);
    color: var(--accent-green);
    box-shadow: 0 0 0 1px rgba(52,211,153,0.3);
}
[data-bs-theme="light"] .as-path-hop { background: rgba(0,0,0,0.05); color: var(--accent-blue); }
[data-bs-theme="light"] .as-path-hop:hover { background: rgba(37,99,235,0.12); transform: translateY(-1px); }
[data-bs-theme="light"] .as-path-hop.origin {
    background: rgba(22,163,74,0.12);
    color: var(--accent-green);
    box-shadow: 0 0 0 1px rgba(22,163,74,0.3);
}
.as-path-arrow {
    opacity: 0.25;
    margin: 0 0.125rem;
    font-size: 0.75rem;
}

/* --- Whois --- */
.whois-pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    border-radius: 0.75rem;
    padding: 1.25rem;
}

/* --- Copy Btn --- */
.btn-copy .copied-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-green);
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}
.btn-copy.copied .copied-tip { display: block; animation: tooltipIn 0.15s ease; }
@keyframes tooltipIn { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* --- Status Dot --- */
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: var(--accent-green);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.4); }
    50% { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
}

/* --- Tab Content Anim --- */
.tab-content-area { animation: fadeSlide 0.25s ease; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- HTMX --- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* --- Custom Scrollbar (light) --- */
[data-bs-theme="light"] ::-webkit-scrollbar { width: 8px; height: 8px; }
[data-bs-theme="light"] ::-webkit-scrollbar-track { background: #f1f5f9; }
[data-bs-theme="light"] ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
[data-bs-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- Skeleton --- */
.skeleton {
    background: linear-gradient(90deg, var(--bs-tertiary-bg) 25%, var(--bs-secondary-bg) 50%, var(--bs-tertiary-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}
[data-bs-theme="light"] .skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- Footer --- */
footer {
    font-size: 0.8125rem;
}
[data-bs-theme="dark"] footer {
    background: #080c15;
}
[data-bs-theme="light"] footer {
    background: #f0f2f5;
}
.footer-section h6 {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.5;
    margin-bottom: 0.75rem;
}
.footer-section a {
    transition: color 0.15s;
}
.footer-section a:hover {
    color: var(--accent-blue) !important;
}

/* --- Nav Tabs --- */
.nav-tabs { border-bottom: 2px solid var(--bs-border-color); gap: 0.25rem; }
.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 600;
    font-size: 0.875rem;
    opacity: 0.6;
    transition: all 0.15s;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem 0.5rem 0 0;
}
.nav-tabs .nav-link.active {
    border-bottom-color: var(--accent-blue);
    color: var(--accent-blue);
    opacity: 1;
    background: transparent;
}
.nav-tabs .nav-link:hover {
    border-bottom-color: var(--accent-blue);
    opacity: 0.8;
    background: rgba(96,165,250,0.04);
}
.nav-tabs .nav-link .badge {
    font-size: 0.6875rem;
    vertical-align: middle;
}

/* --- Breadcrumbs --- */
.breadcrumb {
    font-size: 0.8125rem;
    padding: 0.5rem 0;
}
.breadcrumb a { color: var(--accent-blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-item.active { font-weight: 600; }
.breadcrumb-item + .breadcrumb-item::before { opacity: 0.4; }

/* --- Form Focus --- */
.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 3px rgba(96,165,250,0.2);
    border-color: var(--accent-blue);
}

/* --- Pagination --- */
.pagination .page-item.active .page-link {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}
.pagination .page-link {
    font-size: 0.875rem;
    border-radius: 0.5rem !important;
    margin: 0 0.125rem;
    transition: all 0.15s;
}
.pagination .page-link:hover {
    background: rgba(96,165,250,0.1);
    color: var(--accent-blue);
}

/* --- List Group Search Results --- */
#search-results .list-group-item,
#home-search-results .list-group-item,
#mobile-search-results .list-group-item {
    border-left: 0; border-right: 0;
    transition: background 0.1s;
    padding: 0.625rem 1rem;
}
#search-results .list-group-item:hover,
#home-search-results .list-group-item:hover,
#mobile-search-results .list-group-item:hover {
    background: rgba(96,165,250,0.06);
}

/* --- Progress Bar (thin) --- */
.progress-thin {
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}
.progress-thin .progress-bar {
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* --- Empty State --- */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
}
.empty-state .empty-icon {
    font-size: 3rem;
    opacity: 0.2;
    margin-bottom: 1rem;
}
.empty-state .empty-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.empty-state .empty-text {
    color: var(--bs-body-color);
    opacity: 0.5;
    font-size: 0.875rem;
}

/* --- Info Row (key-value with icon) --- */
.info-row {
    display: flex;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--bs-border-color);
    gap: 0.75rem;
}
.info-row:last-child { border-bottom: none; }
.info-row-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}
.info-row-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.5;
    min-width: 80px;
}
.info-row-value {
    font-weight: 500;
    font-size: 0.875rem;
    margin-left: auto;
}

/* --- Section Header --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-subtitle {
    font-size: 0.8125rem;
    opacity: 0.5;
}

/* --- Misc --- */
::selection { background: rgba(96,165,250,0.3); }
canvas { image-rendering: crisp-edges; }
#country-filter:focus {
    box-shadow: 0 0 0 3px rgba(96,165,250,0.2);
    border-color: var(--accent-blue);
}

/* --- Mobile Responsive Tables --- */
@media (max-width: 768px) {
    .table-responsive-card thead { display: none; }
    .table-responsive-card tbody tr {
        display: block;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--bs-border-color);
        transition: background 0.1s;
    }
    .table-responsive-card tbody tr:last-child { border-bottom: none; }
    .table-responsive-card tbody tr:hover {
        background: rgba(96,165,250,0.04);
        box-shadow: none;
    }
    .table-responsive-card tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.375rem 1rem;
        border: none;
        white-space: normal;
        font-size: 0.875rem;
    }
    .table-responsive-card tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        opacity: 0.45;
        flex-shrink: 0;
        margin-right: 1rem;
        min-width: 80px;
    }
    .table-responsive-card tbody td:first-child { padding-top: 0.625rem; }
    .table-responsive-card tbody td:last-child  { padding-bottom: 0.625rem; }
    /* Stat value responsive */
    .stat-value { font-size: 1.5rem; }
    /* Hide non-critical columns on mobile */
    .table .d-mobile-none { display: none !important; }
}

/* Small screen adjustments */
@media (max-width: 576px) {
    .stat-value { font-size: 1.375rem; }
    .card-body { padding: 1rem; }
    .nav-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .nav-tabs .nav-link { padding: 0.5rem 0.75rem; font-size: 0.8125rem; white-space: nowrap; }
    /* Stack table-responsive scrolling properly */
    .table-responsive { border: none; }
}

/* --- HTMX Error State --- */
.htmx-error {
    border: 1px solid rgba(248,113,113,0.3);
    border-radius: .75rem;
    padding: 1.5rem;
    text-align: center;
    color: var(--accent-red);
    font-size: .875rem;
}

/* --- IPv6 Adoption Bar --- */
.ipv6-bar { height: 6px; border-radius: 3px; background: var(--bs-border-color); overflow: hidden; }
.ipv6-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(to right, var(--accent-blue), var(--accent-green)); transition: width .6s ease; }

/* --- Country Card Grid --- */
.country-card { transition: transform .2s, box-shadow .2s, border-color .2s; }
.country-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.18); border-color: var(--accent-blue) !important; }

/* --- Health Status dot --- */
.health-dot { display:inline-block; width:8px; height:8px; border-radius:50%; }
.health-dot.ok { background:var(--accent-green); box-shadow:0 0 0 2px rgba(52,211,153,.3); }
.health-dot.warn { background:var(--accent-amber); box-shadow:0 0 0 2px rgba(251,191,36,.3); }
.health-dot.error { background:var(--accent-red); box-shadow:0 0 0 2px rgba(248,113,113,.3); }

/* --- Prefix page path visualization --- */
.path-timeline { border-left: 2px solid var(--bs-border-color); padding-left: 1.25rem; margin-left: .5rem; }
.path-timeline-item { position: relative; padding-bottom: 1.25rem; }
.path-timeline-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: .4rem;
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 2px solid var(--bs-body-bg);
    box-shadow: 0 0 0 2px var(--accent-blue);
}
.path-timeline-item:last-child { padding-bottom: 0; }

/* --- Light mode: Table --- */
[data-bs-theme="light"] .table > thead > tr > th {
    background: #f8fafc;
    color: #475569;
}
[data-bs-theme="light"] .table-hover > tbody > tr:hover {
    background: rgba(37,99,235,0.04);
}

/* --- Light mode: Search dropdown --- */
[data-bs-theme="light"] #search-results,
[data-bs-theme="light"] #home-search-results,
[data-bs-theme="light"] #mobile-search-results {
    box-shadow: 0 12px 40px rgba(15,23,42,0.12), 0 0 0 1px rgba(15,23,42,0.05);
}

/* --- Light mode: Footer --- */
[data-bs-theme="light"] footer {
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
}

/* --- Light mode: Form --- */
[data-bs-theme="light"] .form-control {
    border-color: #cbd5e1;
    background: #fff;
}
[data-bs-theme="light"] .form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* --- Light mode: Nav tabs --- */
[data-bs-theme="light"] .nav-tabs {
    border-bottom-color: #e2e8f0;
}
[data-bs-theme="light"] .nav-tabs .nav-link:hover {
    background: rgba(37,99,235,0.04);
}

/* --- Light mode: Navbar nav-link --- */
[data-bs-theme="light"] .navbar .nav-link {
    color: #374151;
}
[data-bs-theme="light"] .navbar .nav-link:hover {
    color: #111827;
    background: rgba(37,99,235,0.06);
}

/* --- Light mode: Whois --- */
[data-bs-theme="light"] .whois-pre {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

/* --- Light mode: AS path hop --- */
[data-bs-theme="light"] .as-path-hop {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}
[data-bs-theme="light"] .as-path-hop:hover {
    background: #dbeafe;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}
[data-bs-theme="light"] .as-path-hop.origin {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    box-shadow: 0 0 0 1px rgba(22,163,74,0.2);
}

/* --- Light mode: Navbar border image (subtle gradient) --- */
[data-bs-theme="light"] nav.navbar {
    border-image: none;
    border-bottom: 1px solid #e2e8f0;
}

/* --- Light mode: Status dot --- */
[data-bs-theme="light"] .status-dot {
    box-shadow: 0 0 0 0 rgba(22,163,74,0.3);
}

/* --- Glass card variant for hero section --- */
.card-glass {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
[data-bs-theme="dark"] .card-glass {
    background: rgba(17, 24, 39, 0.7) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
}
[data-bs-theme="light"] .card-glass {
    background: rgba(255,255,255,0.8) !important;
    border: 1px solid rgba(37,99,235,0.1) !important;
    box-shadow: 0 4px 24px rgba(15,23,42,0.08) !important;
}

/* --- Gradient text (accent) --- */
.text-gradient-blue {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Modern Table Enhancements --- */
.table > tbody > tr:first-child > td { border-top: none; }
.table-sm > tbody > tr > td { padding: 0.5rem 1rem; }
/* Zebra stripe — subtle in light mode */
[data-bs-theme="light"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(241,245,249,0.7);
}
/* Rounded first/last cell for cleaner look */
.table:not(.table-borderless) > tbody > tr:last-child > td:first-child { border-bottom-left-radius: 0.75rem; }
.table:not(.table-borderless) > tbody > tr:last-child > td:last-child  { border-bottom-right-radius: 0.75rem; }

/* --- Modern Card Improvements --- */
.card-header {
    font-size: 0.875rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color);
    font-weight: 600;
}
[data-bs-theme="light"] .card-header {
    background: rgba(248,250,252,0.8);
}
[data-bs-theme="dark"] .card-header {
    background: rgba(255,255,255,0.02);
}
.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--bs-border-color);
    font-size: 0.8125rem;
}
[data-bs-theme="light"] .card-footer { background: rgba(248,250,252,0.6); }
[data-bs-theme="dark"] .card-footer  { background: rgba(255,255,255,0.02); }

/* --- Button Improvements --- */
.btn {
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 0.625rem;
    transition: all 0.15s ease;
}
.btn-sm { font-size: 0.8125rem; padding: 0.35rem 0.875rem; border-radius: 0.5rem; }
.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}
[data-bs-theme="light"] .btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 1px 3px rgba(37,99,235,0.25);
}
[data-bs-theme="light"] .btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}
.btn-outline-primary { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-outline-primary:hover { background: var(--accent-blue); color: #fff; }
[data-bs-theme="light"] .btn-outline-primary { border-color: #2563eb; color: #2563eb; }
[data-bs-theme="light"] .btn-outline-primary:hover { background: #2563eb; color: #fff; }

/* --- Input improvements --- */
.form-control, .form-select {
    border-radius: 0.625rem;
    font-size: 0.875rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
[data-bs-theme="light"] .form-control, [data-bs-theme="light"] .form-select {
    border-color: #cbd5e1;
}

/* --- Mobile: Better spacing --- */
@media (max-width: 576px) {
    .container-xl { padding-left: 1rem; padding-right: 1rem; }
    .row.g-4 { --bs-gutter-y: 1rem; }
    .card { border-radius: 0.75rem; }
    /* Compact breadcrumb on mobile */
    .breadcrumb { font-size: 0.75rem; }
    /* Tighter stat cards */
    .stat-value { font-size: 1.25rem; }
    .stat-label { font-size: 0.625rem; }
    /* Better mobile hero */
    main > .container-xl { padding-top: 1.25rem; padding-bottom: 1.25rem; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Print --- */
@media print {
    .navbar, footer, .btn-copy, .nav-tabs { display: none !important; }
    .card { border: 1px solid #ddd !important; break-inside: avoid; }
}

/* ============================================================
   Mobile UI Improvements
   ============================================================ */

/* --- Scrollable Tab Bar (used in asn.html, prefix.html) --- */
.nav-tabs-scroll-wrapper {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border-bottom: 2px solid var(--bs-border-color);
}
.nav-tabs-scroll-wrapper::-webkit-scrollbar { display: none; }
.nav-tabs-scroll-wrapper > .nav-tabs {
    display: inline-flex;
    border-bottom: none;
    flex-wrap: nowrap;
}

/* --- Touch-Friendly Tap Targets --- */
@media (max-width: 991.98px) {
    .nav-tabs .nav-link {
        min-height: 2.75rem;
        padding: .625rem .875rem;
    }
    .pagination .page-link {
        min-width: 2.75rem;
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .dropdown-item { padding: .5rem 1rem; }
    .btn-group-sm .btn { min-height: 2.25rem; }
}

/* --- Ranks Page: Mobile Layout --- */
.table-ranks td, .table-ranks th { padding: .625rem .875rem; }
@media (max-width: 575.98px) {
    /* Sort buttons: fill width */
    .ranks-sort .btn-group { width: 100%; }
    .ranks-sort .btn-group .btn { flex: 1; font-size: .75rem; padding: .35rem .5rem; }
    /* Country filter: fill width */
    .ranks-country { width: 100% !important; }
    /* Table: tighter cells */
    .table-ranks td { padding: .5rem .625rem; font-size: .8rem; }
    .table-ranks th { padding: .5rem .625rem; }
    /* Org name can wrap */
    .table-ranks .td-org { white-space: normal; max-width: 140px; line-height: 1.3; }
    /* Rank badge smaller */
    .table-ranks .td-rank { font-size: .75rem; padding-left: .5rem; padding-right: .5rem; }
}

/* --- Communities Page: Mobile --- */
@media (max-width: 575.98px) {
    .table-communities td { padding: .5rem .625rem; font-size: .8rem; }
    .table-communities .td-desc {
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* --- ASN Header Stats: extra-small screens --- */
@media (max-width: 479.98px) {
    .asn-stat-row .stat-value { font-size: 1rem; }
    .asn-stat-row .stat-label { font-size: .55rem; }
}

/* --- Card Footer: stack on xs --- */
@media (max-width: 575.98px) {
    .card-footer.d-flex { flex-direction: column; align-items: stretch !important; gap: .75rem !important; }
    .card-footer .pagination { align-self: center; }
}

/* --- General Table: compact on mobile --- */
@media (max-width: 575.98px) {
    .table > thead > tr > th { padding: .5rem .75rem; }
    .table > tbody > tr > td { padding: .5rem .75rem; }
    /* Wrappable org/name cells */
    .td-wrap { white-space: normal !important; }
    /* No border-radius confusion in scrollable wrapper */
    .card .table-responsive { border-radius: 0; }
}

/* --- Country page table --- */
.table-country td { white-space: nowrap; }
.table-country .td-wrap { white-space: normal; }
@media (max-width: 575.98px) {
    .table-country td { padding: .5rem .625rem; font-size: .8rem; }
    .table-country th { padding: .5rem .625rem; }
}

/* --- ASN / Prefix tabs: compact on very small screens --- */
@media (max-width: 479.98px) {
    .nav-tabs-scroll-wrapper .nav-link { padding: .45rem .6rem; font-size: .8rem; }
    .nav-tabs-scroll-wrapper .nav-link .badge { font-size: .55rem; padding: .15em .45em; }
    .nav-tabs-scroll-wrapper .nav-link .bi { margin-right: .2rem !important; }
}

/* ============================================================
   UI Polish — v4
   ============================================================ */

/* --- Card hover: slightly more lift --- */
.card-hover {
    transition: box-shadow .18s ease, transform .18s ease;
    cursor: default;
}
.card-hover:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,.10);
    transform: translateY(-2px);
}
[data-bs-theme="dark"] .card-hover:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
a .card-hover:hover { transform: translateY(-3px); }

/* --- Active nav dropdown toggle --- */
.navbar .nav-link.active {
    color: var(--accent-blue) !important;
    font-weight: 600;
}
.navbar .dropdown-toggle.active::after { border-top-color: var(--accent-blue); }

/* --- Breadcrumb: subtler --- */
.breadcrumb { font-size: .8125rem; }
.breadcrumb-item + .breadcrumb-item::before { opacity: .5; }
.breadcrumb-item.active { color: var(--bs-body-secondary-color); }

/* --- Stat icon: consistent size --- */
.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    border-radius: .625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
}

/* --- RPKI progress bar --- */
.rpki-bar { height: 28px; border-radius: 8px; overflow: hidden; }
.rpki-bar .progress-bar { transition: width .6s ease; }

/* --- Peer tables: RIR badge compact --- */
.peer-rir-col { width: 4.5rem; }

/* --- Home page table: better mobile --- */
@media (max-width: 575.98px) {
    .table-hover td[data-label="Country"] { display: none; }
    .table-hover td[data-label="RIR"] { display: none; }
}

/* --- IPv6 stats table: mobile flag sizes --- */
.ipv6-stat-flag { font-size: 1.25rem; line-height: 1; }

/* --- Info-row: better gap on mobile --- */
@media (max-width: 575.98px) {
    .info-row { gap: .5rem; flex-wrap: wrap; }
    .info-row-label { min-width: 5rem; }
}

/* --- Containing Prefixes table: hide Country on xs --- */
@media (max-width: 575.98px) {
    .table-containing td:nth-child(4),
    .table-containing th:nth-child(4) { display: none; }
}

/* --- Quick Lookup cards: better contrast on hover --- */
.quick-card .card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.10); }
.quick-card .card { transition: box-shadow .18s ease; }

/* --- Section header: consistent style --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}
.section-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* --- Badge: "NEW" accent --- */
.badge-new {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    color: #fff;
    font-size: .6rem;
    padding: .15em .45em;
    border-radius: .25rem;
    vertical-align: middle;
    letter-spacing: .03em;
}

/* --- RPKI stat cards: scale icon on mobile --- */
@media (max-width: 575.98px) {
    .stat-icon { width: 2rem; height: 2rem; min-width: 2rem; font-size: .9rem; border-radius: .5rem; }
    .stat-value { font-size: 1.25rem !important; }
}

/* --- Table: no border-radius in responsive wrapper --- */
.table-responsive > .table { border-radius: 0; }
