/* ═══════════════════════════════════════════════════════════
   SignalNet — BLE Detection Network Console
   Dark operational theme. Teal signal-wave identity.
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #080b10;
    --bg-secondary: #0d1117;
    --bg-card: #111820;
    --bg-input: #141c26;
    --bg-hover: #182230;
    --bg-row-alt: #0e1520;

    --border: #1c2736;
    --border-light: #263345;

    --text-primary: #e2e8f0;
    --text-secondary: #8b9ab5;
    --text-muted: #4e5d73;

    /* SignalNet teal — the core identity */
    --accent: #0fd4b4;
    --accent-bright: #14f0cc;
    --accent-dim: #0a2e28;
    --accent-glow: rgba(15, 212, 180, 0.10);
    --accent-glow-strong: rgba(15, 212, 180, 0.18);

    --red: #f04444;
    --red-dim: #2a1216;
    --red-glow: rgba(240, 68, 68, 0.08);

    --green: #22c55e;
    --green-dim: #122a1a;

    --amber: #f5a623;
    --amber-dim: #2a2010;

    --purple: #a78bfa;
    --purple-dim: #1c1630;

    --mono: 'JetBrains Mono', monospace;
    --sans: 'Outfit', sans-serif;

    --radius: 6px;
    --transition: 120ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; scroll-padding-top: 100px; }
body {
    font-family: var(--sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Top Nav ────────────────────────────────────────────── */

.topnav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
}

.topnav-brand .logo-icon {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--accent) 0%, #0a9e8a 100%);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: #080b10; letter-spacing: -0.5px;
    box-shadow: 0 0 12px rgba(15, 212, 180, 0.25);
    position: relative;
}

.topnav-brand .logo-text {
    font-family: var(--mono);
    font-weight: 700; font-size: 16px;
    color: var(--text-primary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.topnav-brand .logo-text .logo-accent {
    color: var(--accent);
}

.topnav-links { display: flex; align-items: center; gap: 2px; }
.topnav-links a {
    font-weight: 500; font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.topnav-links a:hover { color: var(--text-primary); background: var(--bg-hover); }
.topnav-links a.active { color: var(--accent); background: var(--accent-glow); }

.topnav-user { display: flex; align-items: center; gap: 12px; }
.topnav-user .user-label { font-size: 13px; color: var(--text-muted); font-family: var(--mono); }
.topnav-user .user-role {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
    padding: 3px 8px; border-radius: 3px; font-weight: 600;
}
.topnav-user .user-role.admin { background: var(--amber-dim); color: var(--amber); }
.topnav-user .user-role.user { background: var(--accent-dim); color: var(--accent); }
.topnav-user a.logout {
    font-size: 13px; color: var(--text-muted);
    text-decoration: none; padding: 4px 8px; border-radius: 3px;
}
.topnav-user a.logout:hover { color: var(--red); background: var(--red-glow); }

/* ── Layout ─────────────────────────────────────────────── */

.page { max-width: 1500px; margin: 0 auto; padding: 24px; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.page-header p { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}

.card-header h2 {
    font-size: 13px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-secondary);
}

.card-body { padding: 20px; }

/* ── Forms ──────────────────────────────────────────────── */

.form-input {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--sans);
    font-size: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.mono { font-family: var(--mono); font-size: 13px; }

select, .form-select {
    padding: 10px 14px;
    font-family: var(--sans); font-size: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none; cursor: pointer;
}
select:focus { border-color: var(--accent); }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.4px;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

/* ── Filter Panel ──────────────────────────────────────── */

.search-container { margin-bottom: 20px; }

.filter-row { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.filter-group label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
}
.filter-grow { flex: 1; min-width: 150px; }

.quick-range-btns { display: flex; gap: 4px; }
.qr-btn {
    padding: 8px 14px;
    font-family: var(--mono); font-size: 13px; font-weight: 500;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.qr-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.qr-btn.qr-active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.filter-tag {
    display: inline-flex; align-items: center;
    font-family: var(--mono); font-size: 12px; font-weight: 500;
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
}

input[type="datetime-local"] { color-scheme: dark; }

/* ── Results ────────────────────────────────────────────── */

#search-results { min-height: 200px; }
.no-results { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 15px; }

.result-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    justify-content: space-between;
}

.result-type {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
}

.result-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.result-count {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* ── Drilldown Header ───────────────────────────────────── */

.drilldown-header {
    margin-bottom: 16px;
}

/* ── Device Identity Card ───────────────────────────────── */

.device-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.device-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.device-card-icon {
    width: 42px; height: 42px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.device-card-icon.amber { background: var(--amber-dim); }
.device-card-icon.green { background: var(--green-dim); }

.device-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.device-card-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    word-break: break-all;
}

.device-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.device-card-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.field-value {
    font-size: 14px;
    font-family: var(--mono);
    color: var(--text-secondary);
}

.device-card-macs {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ── MAC Chips ──────────────────────────────────────────── */

.mac-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.mac-chip {
    display: inline-flex;
    flex-direction: column;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.mac-chip:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.mac-chip.confirmed { border-color: var(--green-dim); }

.mac-chip-addr {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
}

.mac-chip-meta {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Correlation Panels ─────────────────────────────────── */

.correlation-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 12px;
}

.correlation-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.correlation-icon {
    width: 28px; height: 28px;
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.correlation-icon.amber { background: var(--amber-dim); }
.correlation-icon.green { background: var(--green-dim); }

.correlation-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
    flex: 1;
}

.correlation-details {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.8;
}

/* ── View Tabs ──────────────────────────────────────────── */

.view-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.view-tab {
    padding: 10px 20px;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.view-tab:hover { color: var(--text-primary); }
.view-tab.tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Map ────────────────────────────────────────────────── */

.sightings-map {
    height: 450px;
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.map-arrow {
    color: var(--amber);
    font-size: 14px;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    background: none !important;
    border: none !important;
}

.gw-map-label {
    background: none !important;
    border: none !important;
    white-space: nowrap;
}
.gw-map-label span {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(13, 17, 23, 0.85);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* Leaflet dark theme overrides */
.leaflet-container { background: var(--bg-primary); }
.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.leaflet-popup-tip { background: var(--bg-card); border: 1px solid var(--border); }
.leaflet-popup-close-button { color: var(--text-muted) !important; }
.leaflet-popup-close-button:hover { color: var(--text-primary) !important; }

/* ── Tables ─────────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: var(--thead-top, 54px);
    z-index: 10;
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    line-height: 1.5;
}

.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:first-child td { scroll-margin-top: calc(var(--thead-top, 54px) + 42px); }
.data-table tbody tr:nth-child(even) { background: var(--bg-row-alt); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.row-watchlisted { background: var(--red-glow); }

.data-table .mono { font-family: var(--mono); font-size: 12px; }

.td-time { white-space: nowrap; }
.td-time .time-date { font-size: 11px; color: var(--text-muted); }
.td-time .time-clock { font-size: 13px; color: var(--text-secondary); font-family: var(--mono); font-weight: 500; }

.td-blename { font-size: 12px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.td-device { font-size: 12px; }
.td-device .device-known { color: var(--text-primary); font-weight: 500; }
.td-device .device-unknown { color: var(--text-muted); font-style: italic; }

.td-type .type-public { color: var(--green); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.td-type .type-random { color: var(--amber); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }

.mac-link {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
}
.mac-link:hover { text-decoration: underline; }

.gw-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
}
.gw-link:hover { color: var(--text-primary); }

.fp-link {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--green);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
}
.fp-link:hover { text-decoration: underline; }

.rssi { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 2px 6px; border-radius: 3px; }
.rssi.strong { color: var(--green); background: var(--green-dim); }
.rssi.medium { color: var(--amber); background: var(--amber-dim); }
.rssi.weak { color: var(--red); background: var(--red-dim); }

/* ── Pagination ─────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: var(--mono);
}

.pagination-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ── Back Button ────────────────────────────────────────── */

.btn-back {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    font-family: var(--sans); font-size: 13px; font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    margin-bottom: 12px;
}
.btn-back:hover { background: var(--bg-hover); border-color: var(--border-light); color: var(--text-primary); }
.btn-back::before { content: "←"; font-size: 15px; }

/* ── Badges ─────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600;
    padding: 3px 10px; border-radius: 4px; white-space: nowrap;
}
.badge-active { background: var(--green-dim); color: var(--green); }
.badge-inactive { background: var(--red-dim); color: var(--red); }
.badge-stale { background: var(--amber-dim); color: var(--amber); }
.badge-offline { background: var(--red-dim); color: var(--red); }
.badge-watchlisted { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.badge-admin { background: var(--amber-dim); color: var(--amber); }

.text-warning { color: var(--amber); }
.badge-user { background: var(--accent-dim); color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    font-family: var(--sans); font-size: 14px; font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #0aa890 100%);
    border-color: var(--accent);
    color: #080b10;
    font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-bright) 0%, var(--accent) 100%); }
.btn-primary:disabled { opacity: 0.7; cursor: default; }
.btn-danger { color: var(--red); border-color: var(--red-dim); }
.btn-danger:hover { background: var(--red-dim); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ghost { background: transparent; border: none; color: var(--text-secondary); padding: 5px 10px; }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Login Page ─────────────────────────────────────────── */

.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 120%, rgba(15, 212, 180, 0.06) 0%, transparent 70%);
}

.login-card {
    width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 36px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.login-card .login-brand {
    display: flex; align-items: center; gap: 12px; margin-bottom: 28px;
    justify-content: center;
}
.login-card .login-brand .logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent) 0%, #0a9e8a 100%);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; color: #080b10;
    box-shadow: 0 0 16px rgba(15, 212, 180, 0.3);
}
.login-card .login-brand .logo-text {
    font-family: var(--mono); font-weight: 700; font-size: 20px;
    color: var(--text-primary); letter-spacing: 2px; text-transform: uppercase;
}
.login-card .login-brand .logo-text .logo-accent { color: var(--accent); }

.login-card .error-msg {
    background: var(--red-dim);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}
.login-card .form-group { margin-bottom: 18px; }
.login-card .btn-primary { width: 100%; padding: 13px; font-size: 15px; font-weight: 600; }

/* ── HTMX Indicator ─────────────────────────────────────── */

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

.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-bar {
    position: fixed; top: 54px; left: 0; right: 0;
    height: 2px; background: var(--accent);
    animation: loading 1s ease-in-out infinite;
    z-index: 200;
}
@keyframes loading {
    0% { transform: scaleX(0); transform-origin: left; }
    50% { transform: scaleX(1); transform-origin: left; }
    50.01% { transform: scaleX(1); transform-origin: right; }
    100% { transform: scaleX(0); transform-origin: right; }
}

/* ── Vendor & Category Badges ───────────────────────────── */

.vendor-known { color: var(--text); font-size: 12px; }

.category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.cat-vehicle    { background: #122a1a; color: #4ade80; }
.cat-tracker    { background: #2a2010; color: #fb923c; }
.cat-phone      { background: #0f2030; color: #60a5fa; }
.cat-audio      { background: #1c1630; color: #c084fc; }
.cat-wearable   { background: #0f2828; color: #2dd4bf; }
.cat-beacon     { background: #2a2a10; color: #facc15; }
.cat-iot-module { background: #1a1a1e; color: #a1a1aa; }
.cat-medical    { background: #2a1216; color: #f87171; }
.cat-random     { background: #141418; color: #71717a; }
.cat-samsung-device  { background: #0f2030; color: #60a5fa; }
.cat-microsoft-device { background: #0f2030; color: #60a5fa; }
.cat-apple-device { background: #141418; color: #a1a1aa; }
.cat-google-device { background: #122a1a; color: #4ade80; }
.cat-smart-home { background: #1a2810; color: #a3e635; }
.cat-phone-computer { background: #0f2030; color: #60a5fa; }

.td-vendor { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-category { white-space: nowrap; }

/* ── Utilities ──────────────────────────────────────────── */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-12 { margin-top: 12px; }
/* ── Detection method badges ─────────────────────────── */
.detection-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.4;
}
.det-adv { background: var(--bg-tertiary); color: var(--text-muted); }
.det-scanrsp { background: rgba(59,130,246,0.15); color: #60a5fa; }
.det-eas { background: rgba(168,85,247,0.15); color: #c084fc; }
.det-oas { background: rgba(240,68,68,0.15); color: #f87171; border: 1px solid rgba(240,68,68,0.3); }
.det-gatt { background: var(--amber-dim); color: var(--amber); }

.confidence-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-left: 3px;
    vertical-align: middle;
}
.conf-real { background: rgba(34,197,94,0.2); color: #4ade80; border: 1px solid rgba(34,197,94,0.4); }
.conf-static { background: rgba(59,130,246,0.15); color: #60a5fa; }
.conf-inferred { background: rgba(251,191,36,0.15); color: #fbbf24; }

.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mono { font-family: var(--mono); }

/* ═══════════════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════════════ */

.site-footer {
    margin-top: 48px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    padding: 24px;
}

.footer-inner {
    max-width: 1500px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.footer-logo {
    width: 24px; height: 24px;
    background: linear-gradient(135deg, var(--accent) 0%, #0a9e8a 100%);
    border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: #080b10;
    letter-spacing: -0.5px;
}

.footer-accent { color: var(--accent); }

.footer-copy {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════
   Mobile / Responsive
   ═══════════════════════════════════════════════════════════ */

/* Hamburger toggle (hidden on desktop) */
.nav-toggle {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 6px;
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
}

/* Responsive tables — horizontal scroll */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

/* Disable sticky thead on specific pages (watchlist, gateways) */
.no-sticky-thead .data-table th {
    position: static;
}

@media (max-width: 900px) {
    /* ── Nav: hamburger ── */
    .nav-toggle { display: block; }

    .topnav {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
        gap: 0;
    }
    .topnav-brand { order: 1; }
    .nav-toggle { order: 2; margin-left: auto; }

    .topnav-links, .topnav-user {
        display: none;
        width: 100%;
        order: 3;
    }
    .topnav-links {
        flex-direction: column;
        gap: 0;
        padding: 8px 0 4px;
        border-top: 1px solid var(--border);
        margin-top: 8px;
    }
    .topnav-links a {
        padding: 10px 12px;
        border-radius: 0;
    }
    .topnav-user {
        padding: 8px 0;
        border-top: 1px solid var(--border);
        justify-content: space-between;
    }

    /* Show when open */
    .topnav.nav-open .topnav-links,
    .topnav.nav-open .topnav-user { display: flex; }

    /* ── Layout ── */
    .page { padding: 16px 12px; }
    .page-header h1 { font-size: 18px; }

    /* ── Search filters: stack vertically ── */
    .filter-row {
        flex-direction: column;
        gap: 10px;
    }
    .filter-group {
        width: 100%;
        min-width: 0 !important;
    }
    .filter-group label { text-align: left; }
    .filter-group input,
    .filter-group select {
        width: 100%;
    }
    .filter-grow { min-width: 0; }

    .quick-range-btns {
        flex-wrap: wrap;
    }
    .qr-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* ── Cards ── */
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }

    /* ── Tables: scroll horizontally ── */
    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 12px;
    }
    .data-table th { top: 0; } /* unstick on mobile */

    .td-time .time-date { font-size: 10px; }
    .td-time .time-clock { font-size: 12px; }
    .td-blename { max-width: 100px; }
    .td-vendor { max-width: 100px; }
    .mac-link { font-size: 11px; }

    /* ── Correlation panels ── */
    .correlation-header { flex-wrap: wrap; gap: 6px; }
    .correlation-title { font-size: 12px; }

    /* ── Device card ── */
    .device-card { padding: 14px; }
    .device-card-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* ── Map ── */
    .sightings-map { height: 300px; }

    /* ── Pagination ── */
    .pagination { flex-direction: column; align-items: stretch; }
    .pagination-btns { justify-content: center; }

    /* ── Watchlist add form ── */
    .watchlist-add-form [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Gateways form ── */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* ── Login ── */
    .login-card { width: 90%; padding: 24px; }

    /* ── Footer ── */
    .footer-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
    }
    .site-footer { padding: 20px 16px; margin-top: 32px; }
}

/* ═══ WiFi-specific styles ═══════════════════════════════ */

.confidence-bar {
    display: inline-block;
    position: relative;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--mono);
    padding: 2px 8px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-dim) var(--conf), transparent var(--conf));
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.detail-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--bg-hover) !important; }

.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid var(--purple); }
.badge-amber { background: var(--amber-dim); color: var(--amber); border: 1px solid var(--amber); }
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }

.pulse {
    animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(240, 68, 68, 0.4); }
    50% { box-shadow: 0 0 8px 2px rgba(240, 68, 68, 0.15); }
}

.mt-16 { margin-top: 16px; }
.p-0 { padding: 0 !important; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

@media (max-width: 600px) {
    /* Even smaller: hide less-important table columns */
    .data-table .td-vendor,
    .data-table .td-category { display: none; }

    .device-card-grid {
        grid-template-columns: 1fr;
    }

    .mac-chips { gap: 4px; }
    .mac-chip { padding: 4px 8px; }
    .mac-chip-addr { font-size: 11px; }
}

/* ── Utilities ───────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Status indicators (header) ─────────────────────────── */

.status-indicators {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: 4px;
}

.status-dot {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 2px 5px;
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.status-dot.status-ok {
    background: var(--green-dim);
    color: var(--green);
    border-color: rgba(34,197,94,0.25);
}

.status-dot.status-err {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(240,68,68,0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

/* ── Stats row (gateways page) ──────────────────────────── */

.stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 80px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    text-align: center;
}

.stat-value {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Gateway inline modal ───────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}

.modal-box h2 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── User menu dropdown ───────────────────────────────── */

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}
.user-menu-trigger:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 300;
    overflow: hidden;
}
.user-menu-dropdown.open {
    display: block;
}

.user-menu-item {
    display: block;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.user-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.user-menu-danger {
    color: var(--text-muted);
}
.user-menu-danger:hover {
    color: var(--red);
    background: var(--red-glow);
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 2px 0;
}

/* ── Trackability badges ─────────────────────────────── */

.track-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 3px;
    white-space: nowrap;
    text-transform: uppercase;
}
.track-permanent {
    background: rgba(0, 200, 100, 0.15);
    color: #00c864;
    border: 1px solid rgba(0, 200, 100, 0.3);
}
.track-today {
    background: rgba(255, 160, 0, 0.15);
    color: #ffa000;
    border: 1px solid rgba(255, 160, 0, 0.3);
}
.track-fingerprint {
    background: rgba(0, 180, 255, 0.12);
    color: #00b4ff;
    border: 1px solid rgba(0, 180, 255, 0.25);
}
.track-unresolved {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
