:root {
    --bg: #09090b;
    --bg2: #111113;
    --surface: #18181b;
    --surface2: #27272a;
    --border: #3f3f46;
    --text: #fafafa;
    --muted: #a1a1aa;
    --dim: #71717a;
    --accent: #e11d74;
    --accent-soft: rgba(225, 29, 116, 0.14);
    --green: #22c55e;
    --green-glow: rgba(34, 197, 94, 0.35);
    --red: #ef4444;
    --blue: #3b82f6;
    --purple: #a855f7;
    --orange: #f59e0b;
    --sidebar: 260px;
    --topbar: 64px;
    --bottom: 64px;
    --radius: 14px;
    --font: 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 50% 40% at 0% 0%, rgba(225,29,116,0.07), transparent 55%),
        radial-gradient(ellipse 40% 30% at 100% 0%, rgba(168,85,247,0.06), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 18px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b, #ef4444, #ec4899, #a855f7);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.85rem;
}

.brand-title { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.72rem; color: var(--dim); }

.device-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
}

.device-card-clickable {
    cursor: pointer;
    transition: border-color 0.2s;
}

.device-card-clickable:hover {
    border-color: rgba(244, 114, 182, 0.4);
}

.device-card-sub {
    font-size: 0.68rem;
    color: var(--dim);
    line-height: 1.2;
}

.device-alias-btn {
    border: none;
    background: var(--surface2);
    color: var(--muted);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.device-alias-btn:hover {
    color: var(--text);
    background: var(--accent-soft);
}

.device-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-tag-model {
    display: block;
    font-size: 0.65rem;
    opacity: 0.75;
    font-weight: 400;
}

.alias-modal-body {
    max-width: 420px;
}

.alias-modal-title {
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.alias-modal-desc {
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: var(--muted);
}

.alias-device-info {
    background: var(--surface2);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 0.82rem;
}

.alias-device-info small {
    color: var(--dim);
    word-break: break-all;
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--red);
    flex-shrink: 0;
}

.pulse.online {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--green-glow); }
    50% { box-shadow: 0 0 0 6px transparent; }
}

.device-card-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.device-card-text strong {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-card-text span { font-size: 0.7rem; color: var(--dim); }

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: 0.15s;
    width: 100%;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #f9a8d4; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface2);
    color: var(--muted);
}

.nav-item.active .nav-badge {
    background: var(--accent);
    color: #fff;
}

.sidebar-foot {
    font-size: 0.68rem;
    color: var(--dim);
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 10px;
}

/* Main */
.main {
    flex: 1;
    margin-left: var(--sidebar);
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

.topbar {
    height: var(--topbar);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.menu-btn svg { width: 20px; height: 20px; }

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; }
.topbar-title p { font-size: 0.75rem; color: var(--dim); }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.device-select {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    max-width: 220px;
    min-width: 140px;
}

.device-select.full {
    width: 100%;
    max-width: none;
}

.device-select:focus {
    outline: none;
    border-color: var(--accent);
}

.device-switch {
    font-weight: 600;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 95;
}

.sidebar-overlay.show { display: block; }

@media (min-width: 901px) {
    .sidebar-overlay { display: none !important; }
}

.hidden { display: none !important; }

.sidebar-devices {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    max-height: 180px;
    overflow-y: auto;
}

.sidebar-device-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.75rem;
    width: 100%;
}

.sidebar-device-item:hover,
.sidebar-device-item.active {
    border-color: var(--border);
    color: var(--text);
    background: var(--accent-soft);
}

.sidebar-device-item .pulse { flex-shrink: 0; }

.sidebar-device-item strong {
    display: block;
    color: var(--text);
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.device-card-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}

.device-card-panel:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.device-card-panel.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
}

.device-card-panel.offline { opacity: 0.72; }

.device-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.device-card-head h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.device-card-head small {
    color: var(--dim);
    font-size: 0.7rem;
    word-break: break-all;
}

.device-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.device-card-stats .stat {
    background: var(--bg2);
    border-radius: 10px;
    padding: 8px 10px;
}

.log-tag.device {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.command-target-panel { margin-bottom: 12px; }

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
}

.dot.online { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }

.content {
    padding: 20px 24px 32px;
    flex: 1;
}

.page { display: none; animation: fadeIn 0.2s ease; }
.page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* Dashboard */
.hero {
    background: linear-gradient(135deg, #1e1b4b, #312e81 45%, #4c1d95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.hero h2 { font-size: 1.2rem; margin-bottom: 4px; }
.hero-sub { font-size: 0.8rem; color: rgba(255,255,255,0.6); margin-bottom: 18px; }
.hero-loading { color: rgba(255,255,255,0.5); }

.hero-offline {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hero-offline-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(0,0,0,0.25);
    display: grid;
    place-items: center;
    font-size: 1.5rem;
}

.device-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stat {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 12px;
}

.stat-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.5);
    margin-bottom: 4px;
}

.stat-value { font-size: 0.92rem; font-weight: 600; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

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

.stat-card .stat-label {
    display: block;
    font-size: 0.72rem;
    color: var(--dim);
    margin-bottom: 6px;
    text-transform: none;
    letter-spacing: 0;
}

.stat-card strong { font-size: 1.4rem; font-weight: 700; }

.quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.quick-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: 0.15s;
}

.quick-card span { font-size: 1.4rem; }
.quick-card b { font-size: 0.9rem; }
.quick-card small { font-size: 0.72rem; color: var(--dim); }
.quick-card:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Panels */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.panel-head { margin-bottom: 16px; }
.panel-head h2 { font-size: 1rem; font-weight: 700; margin-bottom: 2px; }
.panel-head p { font-size: 0.78rem; color: var(--dim); }

.action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 10px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}

.action-btn span { font-size: 1.3rem; }
.action-btn:hover { background: var(--surface2); transform: translateY(-1px); }
.action-btn.danger:hover { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); }
.action-btn:disabled,
.action-btn.cmd-disabled,
.btn.cmd-disabled:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}
.cap-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.cap-bar.hidden { display: none; }
.cap-chip {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--muted);
}
.cap-chip.on {
    border-color: rgba(34, 197, 94, 0.35);
    color: #86efac;
    background: rgba(34, 197, 94, 0.08);
}
.cap-chip.off {
    border-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.06);
}

.field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    margin-top: 12px;
}

input, textarea {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    font-size: 0.9rem;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
    margin-top: 14px;
}

.btn.primary {
    width: 100%;
    background: linear-gradient(135deg, #f59e0b, #ef4444, #ec4899);
    color: #fff;
}

.btn.secondary {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn.ghost {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--muted);
    margin-top: 0;
    padding: 10px 14px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn.danger {
    width: 100%;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}

.btn.danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn.danger-text { color: #f87171; }

.clear-log-select-all {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 4px;
    margin-bottom: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
}

.clear-log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.clear-log-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: 0.15s;
}

.clear-log-item:hover { border-color: rgba(255,255,255,0.12); }

.clear-log-item input { width: 18px; height: 18px; accent-color: var(--accent); }

.clear-log-icon { font-size: 1.35rem; line-height: 1; }

.clear-log-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.clear-log-label b { font-size: 0.9rem; }

.clear-log-label small { font-size: 0.75rem; color: var(--dim); }

.clear-log-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Toolbar & logs */
/* Date filter */
.date-filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.date-filter-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.date-filter-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.date-range-label {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

.date-filter-device {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.date-filter-device label {
    font-size: 12px;
    color: var(--dim);
    font-weight: 500;
}

.date-filter-device .device-select {
    flex: 1 1 180px;
    min-width: 0;
}

.date-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.date-shortcut {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.date-shortcut:hover {
    border-color: var(--accent);
    color: var(--text);
}

.date-shortcut.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
}

.date-range-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.date-range-row input[type="date"] {
    flex: 1 1 130px;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg2);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
}

.date-range-row input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

.date-sep {
    font-size: 12px;
    color: var(--dim);
}

.btn.sm {
    padding: 8px 12px;
    font-size: 12px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.toolbar input[type="search"] {
    flex: 1 1 200px;
    min-width: 0;
    margin: 0;
}

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }

.chip-btn {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--dim);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.chip-btn.active {
    background: var(--accent-soft);
    border-color: rgba(225,29,116,0.4);
    color: #f9a8d4;
}

.mini-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--dim);
    margin-bottom: 14px;
}

.mini-stats b { color: var(--text); }

.log-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding-right: 4px;
}

.log-list::-webkit-scrollbar { width: 5px; }
.log-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.log-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    border-left: 3px solid var(--border);
}

.log-card.type-notification { border-left-color: var(--accent); }
.log-card.type-location { border-left-color: var(--blue); }
.log-card.type-file { border-left-color: var(--green); }
.log-card.type-command { border-left-color: var(--orange); }
.log-card.type-text { border-left-color: var(--purple); }
.log-card.type-system-info { border-left-color: var(--blue); }
.log-card.type-system-warn { border-left-color: var(--orange); }
.log-card.type-system-error { border-left-color: var(--red); }
.log-card.type-keylog-keys { border-left-color: var(--purple); }
.log-card.type-keylog-notif { border-left-color: var(--green); }

.log-tag.keys { background: rgba(168,85,247,0.15); color: #d8b4fe; }
.log-tag.app { background: rgba(255,255,255,0.06); color: var(--muted); }
.log-tag.dim { background: transparent; color: var(--dim); font-size: 0.68rem; }

.keylog-text {
    font-family: ui-monospace, monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.log-time { font-size: 0.68rem; color: var(--dim); margin-left: auto; }

.log-tag {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--surface2);
    color: var(--muted);
}

.log-tag.notif { background: var(--accent-soft); color: #f9a8d4; }
.log-tag.file { background: rgba(34,197,94,0.15); color: #86efac; }
.log-tag.location { background: rgba(59,130,246,0.15); color: #93c5fd; }
.log-tag.command { background: rgba(245,158,11,0.15); color: #fcd34d; }
.log-tag.info { background: rgba(59,130,246,0.15); color: #93c5fd; }
.log-tag.warn { background: rgba(245,158,11,0.15); color: #fcd34d; }

.log-body {
    font-size: 0.86rem;
    color: var(--muted);
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

.log-body strong { color: var(--text); }

.log-card a {
    display: inline-block;
    margin-top: 8px;
    color: var(--blue);
    font-size: 0.78rem;
    text-decoration: none;
}

.log-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--dim);
}

.log-empty-icon { font-size: 2rem; margin-bottom: 10px; opacity: 0.5; }

/* SMS threads */
.sms-thread {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
}

.sms-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}

.sms-thread-from { font-weight: 700; font-size: 0.9rem; }
.sms-thread-meta { font-size: 0.72rem; color: var(--dim); margin-top: 2px; }
.sms-thread-count {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface2);
}

.sms-thread.collapsed .sms-thread-body { display: none; }

.sms-bubble {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sms-bubble-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.sms-type {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
}

.sms-type.inbox { background: rgba(59,130,246,0.15); color: #93c5fd; }
.sms-type.sent { background: rgba(34,197,94,0.15); color: #86efac; }

/* Keylog */
.keylog-batch {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
}

.keylog-batch-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg2);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.keylog-batch-title { font-weight: 700; font-size: 0.9rem; }
.keylog-batch-meta { font-size: 0.72rem; color: var(--dim); margin-top: 2px; }
.keylog-batch.collapsed .keylog-batch-body { display: none; }

.keylog-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.keylog-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
}

.keylog-badge.keys { background: rgba(168,85,247,0.15); color: #d8b4fe; }
.keylog-badge.notif { background: rgba(34,197,94,0.15); color: #86efac; }

.keylog-section-label {
    padding: 8px 16px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--dim);
}

.keylog-line {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-family: ui-monospace, monospace;
    font-size: 0.82rem;
    color: var(--muted);
}

/* Bottom nav mobile */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom);
    background: rgba(17,17,19,0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 90;
    padding: 0 4px env(safe-area-inset-bottom);
    justify-content: space-around;
    align-items: center;
}

.bottom-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--dim);
    font: inherit;
    font-size: 0.62rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    min-width: 52px;
}

.bottom-item span { font-size: 1.1rem; }
.bottom-item.active { color: #f9a8d4; }

.sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 110;
}

.sheet-overlay.show { display: block; }

.more-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    z-index: 120;
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.more-sheet.show { transform: translateY(0); }

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 14px;
}

.more-sheet h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    padding: 0 4px;
}

.sheet-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 12px;
    border: none;
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    margin-bottom: 8px;
    cursor: pointer;
}

.sheet-item:hover { background: var(--surface2); }

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 0.85rem;
    opacity: 0;
    transition: 0.3s;
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.info-banner {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: #bfdbfe;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    margin-bottom: 14px;
    line-height: 1.5;
}

.info-banner code {
    background: rgba(0,0,0,0.25);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

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

.media-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: 0.2s;
}

.media-tab b {
    background: var(--surface2);
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    color: var(--text);
}

.media-tab:hover {
    border-color: rgba(244, 114, 182, 0.35);
    color: var(--text);
}

.media-tab.active {
    background: var(--accent-soft);
    border-color: rgba(244, 114, 182, 0.5);
    color: #f9a8d4;
}

.media-tab.active b {
    background: rgba(0,0,0,0.2);
    color: #fce7f3;
}

.capture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.capture-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
}

.capture-card:hover {
    border-color: rgba(244, 114, 182, 0.45);
    transform: translateY(-2px);
}

.capture-thumb {
    aspect-ratio: 16 / 10;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.capture-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.capture-thumb.placeholder,
.capture-thumb.audio {
    font-size: 2rem;
    color: var(--muted);
}

.capture-card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.capture-card-type {
    font-size: 0.75rem;
    font-weight: 600;
    color: #f9a8d4;
}

.capture-card-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.capture-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.capture-card-foot {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted);
}

.capture-storage { opacity: 0.85; }

.capture-audio {
    width: 100%;
    height: 32px;
    margin-top: 4px;
}

.capture-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.capture-modal.hidden { display: none; }

.capture-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.72);
}

.capture-modal-body {
    position: relative;
    width: min(920px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
}

.capture-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    z-index: 2;
}

.capture-modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.capture-modal-media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: var(--surface2);
    border-radius: 12px;
    overflow: hidden;
}

.capture-modal-media img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.capture-modal-media audio {
    width: 100%;
    padding: 20px;
}

.capture-modal-file {
    padding: 40px;
    font-size: 1.1rem;
    text-align: center;
}

.capture-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn.sm {
    padding: 6px 10px;
    font-size: 0.75rem;
    flex: 1;
    text-align: center;
    text-decoration: none;
}

.capture-modal-media video {
    max-width: 100%;
    max-height: 70vh;
}

.capture-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.btn.full { width: 100%; }

/* Mobile filter trigger */
.mobile-filter-bar {
    display: none;
    margin-bottom: 12px;
}

.filter-trigger-btn {
    display: none;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-trigger-btn .filter-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.filter-trigger-btn .filter-dot.hidden { display: none; }

/* Filter modal (bottom sheet) */
.filter-modal {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.filter-modal.hidden { display: none; }

.filter-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.filter-modal-sheet {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    animation: filterSheetIn 0.25s ease;
}

@keyframes filterSheetIn {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.filter-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px 12px;
    flex-shrink: 0;
}

.filter-modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.filter-modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.filter-modal-footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.filter-modal-footer .btn { flex: 1; }

.filter-section h4 {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 10px;
}

.filter-section .date-shortcuts,
.filter-section .chip-group {
    margin-bottom: 10px;
}

.filter-section .date-range-row {
    margin-top: 4px;
}

.filter-section .date-range-row input[type="date"] {
    flex: 1 1 calc(50% - 20px);
}

.filter-section .device-select {
    width: 100%;
    max-width: none;
}

body.filter-modal-open {
    overflow: hidden;
}

.desktop-only-filters { display: block; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 8px 0 32px rgba(0,0,0,0.4);
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding-bottom: var(--bottom); }
    .menu-btn { display: flex; }
    .bottom-nav { display: flex; }
    .content { padding: 16px 16px 24px; }
    .topbar {
        padding: 0 14px;
        gap: 10px;
        height: auto;
        min-height: var(--topbar);
        padding-top: 8px;
        padding-bottom: 8px;
    }
    .topbar-title p { display: none; }
    .topbar-actions {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }
    .topbar-actions .device-switch {
        display: block;
        max-width: min(42vw, 160px);
        min-width: 0;
        font-size: 0.72rem;
        padding: 6px 8px;
    }
    .status-pill {
        font-size: 0.68rem;
        padding: 5px 8px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .device-select { max-width: none; width: 100%; min-width: 0; }
    .devices-grid { grid-template-columns: 1fr; }
    .action-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .device-stats { grid-template-columns: repeat(2, 1fr); }
    .quick-grid { grid-template-columns: 1fr; }
    .log-list { max-height: calc(100vh - 280px); }
    .toast { bottom: calc(var(--bottom) + 16px); }
    .capture-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .mini-stats {
        gap: 8px 14px;
        font-size: 0.75rem;
        padding: 10px 12px;
    }
    .toolbar {
        display: grid;
        grid-template-columns: 1fr auto auto;
        gap: 8px;
        align-items: center;
    }
    .toolbar input[type="search"] {
        grid-column: 1 / -1;
        width: 100%;
    }
    .desktop-only-filters { display: none !important; }
    .mobile-filter-bar { display: block; }
    .filter-trigger-btn { display: inline-flex; }
    .panel { padding: 16px; }
    .log-card { padding: 12px 14px; }
    .hero { padding: 20px 16px; }
}

@media (max-width: 400px) {
    .capture-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .action-grid { grid-template-columns: 1fr; }
}

@media (min-width: 901px) {
    .bottom-nav { display: none !important; }
}
