/* ByteBlitz VeloInsights — dashboard theme, aligned to the ByteBlitz design tokens. */
:root {
    --bg: #14141f;
    --panel: rgba(40, 40, 66, 0.35);
    --panel-2: #1c1c2e;
    --elevated: #101017;
    --field: #232338;
    --field-border: #3d3d60;
    --map-base: #2b2e3c;
    --border: rgba(61, 61, 96, 0.55);
    --border-soft: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.18);
    --row-hover: rgba(255, 255, 255, 0.04);

    --text: #ffffff;
    --text-body: rgba(255, 255, 255, 0.82);
    --muted: rgba(255, 255, 255, 0.55);
    --faint: rgba(255, 255, 255, 0.4);

    --primary: #5142fc;
    --primary-hover: #3f35af;
    --primary-light: #866efb;
    --secondary: #e250e5;
    --accent: #5142fc;
    --success: #22c55e;
    --warning: #ffc107;
    --danger: #ef4444;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --maxw: 1920px;

    --c1: #5142fc;
    --c2: #e250e5;
    --c3: #22c55e;
    --c4: #ffc107;
    --c5: #866efb;
    --c6: #38bdf8;
    --c7: #fb7185;
    --c8: #94a3b8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text-body);
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--primary-light);
    text-decoration: none;
}

/* ── top bar ── */
header.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand .title {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: .2px;
    color: var(--text);
}

.brand .sub {
    color: var(--muted);
    font-size: 12px;
}

.spacer {
    flex: 1;
}

.range-note {
    color: var(--faint);
    font-size: 12px;
    margin-right: 4px;
}

/* ── buttons ── */
.btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}

.btn:hover {
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.09);
}

.btn:disabled {
    opacity: .4;
    cursor: default;
}

.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn.on {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.rangelabel {
    color: var(--muted);
    font-size: 13px;
    align-self: center;
}

/* ── tabs (pill bar) ── */
nav.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: var(--maxw);
    margin: 20px auto 0;
    padding: 0 16px;
}

nav.tabs button {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 9px 18px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s ease;
}

nav.tabs button:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

nav.tabs button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ── layout ── */
main {
    padding: 20px 16px 40px;
    max-width: var(--maxw);
    margin: 0 auto;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* ── stat cards ── */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.card .k {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.card .v {
    font-size: 28px;
    font-weight: 700;
    margin-top: 6px;
    color: var(--text);
}

/* ── panels ── */
/* Exactly two charts per line on desktop/tablet, one on mobile. minmax(0,1fr) lets wide charts
   (heatmap SVG) scale down inside their half instead of forcing the panel to overflow. */
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 760px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 14px;
    margin-bottom: 16px;
}

.panel h3 {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.panel h3 .muted {
    font-weight: 400;
    font-size: 12px;
}

.panel .chart {
    width: 100%;
}

/* ── filters + chips ── */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}

input, select {
    background: var(--field);
    color: var(--text);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13px;
    min-width: 130px;
}

select {
    cursor: pointer;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(81, 66, 252, 0.25);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.chips:empty {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px 5px 12px;
    border-radius: var(--radius-pill);
    background: rgba(81, 66, 252, 0.16);
    border: 1px solid rgba(81, 66, 252, 0.5);
    color: var(--text);
    font-size: 12px;
}

.chip-x {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 50%;
}

.chip-x:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

/* ── tables ── */
.tablewrap {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--field-border) transparent;
}

.tablewrap::-webkit-scrollbar {
    height: 8px;
}

.tablewrap::-webkit-scrollbar-thumb {
    background: var(--field-border);
    border-radius: 4px;
}

.tablewrap::-webkit-scrollbar-track {
    background: transparent;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 0;
}

th, td {
    text-align: left;
    padding: 6px 7px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: none;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

tbody tr:hover {
    background: var(--row-hover);
}

.trunc {
    display: inline-block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.trunc.vis {
    max-width: 84px;
}

/* ── pills / tags ── */
.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
}

.tag.vpn {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.12);
}

.tag.datacenter {
    color: var(--warning);
    border-color: rgba(255, 193, 7, 0.5);
    background: rgba(255, 193, 7, 0.12);
}

.tag.forge {
    color: var(--primary-light);
    border-color: rgba(134, 110, 251, 0.5);
    background: rgba(134, 110, 251, 0.12);
}

/* ── helpers ── */
.mono {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.muted {
    color: var(--muted);
}

.link {
    cursor: pointer;
    color: var(--primary-light);
}

.link:hover {
    text-decoration: underline;
}

.fil {
    cursor: pointer;
    border-bottom: 1px dotted transparent;
}

.fil:hover {
    color: var(--primary-light);
    border-bottom-color: var(--primary-light);
}

.tag.fil:hover {
    filter: brightness(1.2);
    border-bottom: none;
}

.head {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
    border-radius: 3px;
    image-rendering: pixelated;
}

.flag {
    width: 20px;
    height: 13px;
    margin-right: 7px;
    vertical-align: -2px;
    border-radius: 2px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.pager {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
    color: var(--muted);
    font-size: 13px;
}

/* ── charts ── */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--muted);
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

/* ── demand bar ── */
th.demand-col, td .demandbar-wrap {
    min-width: 64px;
}

.demandbar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.demandbar {
    height: 10px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    min-width: 3px;
    flex: 0 0 auto;
}

.demandbar-val {
    color: var(--muted);
    font-size: 12px;
}

/* ── modal ── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 16, 0.6);
    backdrop-filter: blur(2px);
    z-index: 50;
}

.modal-backdrop.open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 64px 16px;
}

.modal {
    background: #1b1b2a;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 660px;
    width: 100%;
    max-height: 80vh;
    overflow: auto;
    padding: 22px;
    box-shadow: var(--shadow-lg);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal h3 {
    margin: 0;
}

.kv {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 14px;
    font-size: 13px;
    margin-bottom: 8px;
}

.kv .k {
    color: var(--muted);
}

/* ── login ── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 20px;
    margin: 0 0 4px;
    color: var(--text);
}

.login-card p {
    color: var(--muted);
    margin: 0 0 20px;
    font-size: 13px;
}

.login-card input {
    width: 100%;
    margin-bottom: 12px;
}

.login-card .btn {
    width: 100%;
}

.error {
    color: var(--danger);
    font-size: 13px;
    min-height: 18px;
    margin-top: 8px;
}

/* ── visitor quality ── */
.qual {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
    border: 1px solid var(--border);
}

.q-human {
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.12);
}

.q-suspicious {
    color: var(--warning);
    border-color: rgba(255, 193, 7, 0.5);
    background: rgba(255, 193, 7, 0.12);
}

.q-bot {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.12);
}

.qbar {
    display: flex;
    height: 18px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    background: var(--panel-2);
    border: 1px solid var(--border);
}

.qseg {
    height: 100%;
}

.qseg.q-human {
    background: var(--success);
}

.qseg.q-suspicious {
    background: var(--warning);
}

.qseg.q-bot {
    background: var(--danger);
}

.qlegend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--muted);
}

.qlegend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.qlegend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.qlegend i.q-human {
    background: var(--success);
}

.qlegend i.q-suspicious {
    background: var(--warning);
}

.qlegend i.q-bot {
    background: var(--danger);
}

/* ── world choropleth ── */
.mapwrap {
    width: 100%;
}

.worldmap {
    width: 100%;
    height: auto;
    display: block;
}

.worldmap path {
    fill: var(--map-base);
    stroke: var(--bg);
    stroke-width: 0.5;
    transition: fill .15s ease;
}

.worldmap path:hover {
    stroke: var(--border-strong);
    stroke-width: 0.9;
}
