:root {
    --st-bg: #050b14;
    --st-bg-alt: #0b1724;
    --st-bg-soft: #101a28;
    --st-primary: #1e90ff;
    --st-primary-soft: rgba(30, 144, 255, 0.15);
    --st-accent: #f0c330;
    --st-text: #e8f1ff;
    --st-muted: #9aa8c2;
    --st-border: #1f2b3a;
    --st-danger: #e74c3c;
    --st-success: #2ecc71;
    --st-radius-lg: 14px;
    --st-radius-sm: 8px;
    --st-shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.55);
    --st-shadow-chip: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #12233a 0, #050b14 40%, #020308 100%);
    color: var(--st-text);
}

body {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(135deg, #040815 0%, #050b14 40%, #020309 100%);
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, #050b14 0%, #040611 100%);
    border-right: 1px solid var(--st-border);
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 10px 12px;
    border-radius: var(--st-radius-lg);
    background: radial-gradient(circle at top left, #1e90ff40 0, #050b14 45%, #000 100%);
    box-shadow: var(--st-shadow-soft);
    border: 1px solid rgba(135, 206, 250, 0.15);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, #f0c330 0, #1e90ff 40%, #050b14 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    box-shadow: 0 0 0 2px rgba(2, 12, 30, 0.9);
}

.brand-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--st-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.sidebar-section-label {
    margin: 2px 6px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--st-muted);
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    border: 0;
    padding: 8px 10px;
    border-radius: var(--st-radius-sm);
    background: transparent;
    color: var(--st-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background 0.16s ease, color 0.16s ease, transform 0.08s ease;
}

    .nav-btn span.icon {
        width: 20px;
        text-align: center;
        opacity: 0.9;
    }

    .nav-btn:hover {
        background: rgba(255, 255, 255, 0.03);
        color: var(--st-text);
        transform: translateY(-1px);
    }

    .nav-btn.active {
        background: var(--st-primary-soft);
        color: var(--st-text);
        box-shadow: var(--st-shadow-chip);
        border: 1px solid rgba(30, 144, 255, 0.5);
    }

        .nav-btn.active span.icon {
            opacity: 1;
        }

.sidebar-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--st-border);
    font-size: 11px;
    color: var(--st-muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.badge-beta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(135, 206, 250, 0.12);
    border: 1px solid rgba(135, 206, 250, 0.35);
    color: var(--st-text);
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--st-accent);
    box-shadow: 0 0 4px var(--st-accent);
}

/* Main area */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0; /* ⭐ allow content to shrink so inner scroll works */
    padding: 14px 18px 18px;
    gap: 10px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
}

.topbar-subtitle {
    font-size: 12px;
    color: var(--st-muted);
}

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

.chip {
    font-size: 11px;
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--st-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn {
    border-radius: 999px;
    border: 1px solid rgba(135, 206, 250, 0.35);
    background: linear-gradient(135deg, #1e90ff, #00b0ff);
    color: #050b14;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
    transition: transform 0.08s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

    .btn:hover {
        transform: translateY(-1px);
        filter: brightness(1.05);
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.8);
    }

    .btn.secondary {
        background: transparent;
        color: var(--st-muted);
        border-color: var(--st-border);
        box-shadow: none;
    }

        .btn.secondary:hover {
            background: rgba(255, 255, 255, 0.03);
            color: var(--st-text);
        }

    .btn.small {
        padding: 4px 10px;
        font-size: 11px;
        box-shadow: none;
    }

/* Content area */
.content {
    flex: 1;
    min-height: 0;
    border-radius: var(--st-radius-lg);
    background: radial-gradient(circle at top, rgba(30, 144, 255, 0.15) 0, #050b14 32%, #020308 100%);
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: var(--st-shadow-soft);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.view {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 10px;
}

    .view.active {
        display: flex;
    }

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.view-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.view-title {
    font-size: 15px;
    font-weight: 600;
}

.view-subtitle {
    font-size: 12px;
    color: var(--st-muted);
}

.view-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pill {
    font-size: 11px;
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid var(--st-border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--st-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pill-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin: 0 6px;
    background-color: #ffffff; /* base */
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

/* State colors */
.pill-ok {
    background-color: #4caf50;
}

.pill-warning {
    background-color: #e8c14c;
}

.pill-idle {
    background-color: #ffffff;
    box-shadow: 0 0 6px rgba(255,255,255,0.6);
}

/* Layout helpers */
.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr);
    gap: 10px;
    min-height: 0;
}

.card {
    border-radius: var(--st-radius-lg);
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.05) 0, #050b14 40%, #020307 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.65);
    padding: 10px 11px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

/* ⭐ Let the WINDOWS.DB and GATHER results cards stretch the same */
#view-windowsdb .card:last-of-type,
#view-gatherdb .card:last-of-type {
    flex: 1;
    min-height: 0;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-subtitle {
    font-size: 11px;
    color: var(--st-muted);
}

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

.badge-soft {
    font-size: 10px;
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--st-muted);
}

/* Inputs / filters */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.input {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 999px;
    border: 1px solid var(--st-border);
    padding: 6px 10px;
    font-size: 12px;
    color: var(--st-text);
    outline: none;
    min-width: 0;
}

    .input::placeholder {
        color: var(--st-muted);
    }

    .input.short {
        width: 100px;
    }

    .input.medium {
        width: 160px;
    }

    .input.long {
        width: 320px;
        max-width: 420px;
    }

select.input {
    padding-right: 22px;
}

/* Make search box grow nicely in the table header */
.table-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#search-box {
    flex: 1 1 260px;
}

/* Narrow page size dropdown */
#page-size {
    width: 90px;
    max-width: 100px;
}

/* Table */
.table-wrap {
    flex: 1;
    min-height: 0;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(2, 6, 18, 0.95);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-header-bar {
    padding: 6px 9px;
    font-size: 11px;
    color: var(--st-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(90deg, rgba(30,144,255,0.18), transparent);
    gap: 8px;
}

.table-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.filter-pill {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: 11px;
    color: #e5e7eb;
    max-width: 520px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Shared scroll styling for results table and Item Details panel */
.table-scroll,
#view-details {
    flex: 1;
    min-height: 0;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(135,206,250,0.7) transparent;
}

    /* Same Chrome/Edge scrollbar for both */
    .table-scroll::-webkit-scrollbar,
    #view-details::-webkit-scrollbar {
        height: 8px;
        width: 8px;
    }

    .table-scroll::-webkit-scrollbar-track,
    #view-details::-webkit-scrollbar-track {
        background: transparent;
    }

    .table-scroll::-webkit-scrollbar-thumb,
    #view-details::-webkit-scrollbar-thumb {
        background: rgba(135,206,250,0.5);
        border-radius: 10px;
    }

        .table-scroll::-webkit-scrollbar-thumb:hover,
        #view-details::-webkit-scrollbar-thumb:hover {
            background: rgba(135,206,250,0.8);
        }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    min-width: 900px;
    table-layout: fixed; /* important for stable column widths */
}

thead {
    background: #0b1724;
    position: sticky;
    top: 0; /* ⭐ same for windows & gather */
    z-index: 1;
}

th,
td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* keep header one-line */
th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--st-muted);
    position: relative;
    user-select: none;
    white-space: nowrap;
}

/* default cells stay single-line (for dates, ext, etc.) */
td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    /* For Path / URL + Item Name columns (JS adds .cell-wrap) */
    td.cell-wrap {
        white-space: normal;
        word-break: break-all;
        text-overflow: clip;
    }

tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.01);
}

tr:hover td {
    background: rgba(30, 144, 255, 0.12);
}

tr.selected td {
    background: rgba(30, 144, 255, 0.25) !important;
}

/* Column resize handle (used by app.js) */
.col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    cursor: col-resize;
    opacity: 0;
    transition: opacity 0.1s;
}

th:hover .col-resizer {
    opacity: 0.7;
    background: rgba(135, 206, 250, 0.6);
}

/* Sort indicators (used by app.js) */
th.sort-asc::after,
th.sort-desc::after {
    content: '';
    border: 4px solid transparent;
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
}

th.sort-asc::after {
    border-bottom-color: rgba(135, 206, 250, 0.9);
}

th.sort-desc::after {
    border-top-color: rgba(135, 206, 250, 0.9);
}

/* Pager row */
.pager-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    padding: 6px 9px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.page-info {
    color: var(--st-muted);
}

/* Timeline cards */
.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: auto;
    padding-right: 4px;
}

.timeline-day {
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.timeline-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.timeline-pill {
    font-size: 10px;
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(30, 144, 255, 0.08);
    border: 1px solid rgba(30, 144, 255, 0.35);
    color: var(--st-text);
}

/* Item detail */
.kv-list {
    display: grid;
    grid-template-columns: minmax(260px, 1.5fr) minmax(0, 2fr);
    column-gap: 8px;
    row-gap: 4px;
    margin-top: 4px;
}

/* Raw property bag: 3 columns = [checkbox] [label] [value] */
#raw-props.kv-list {
    grid-template-columns: auto minmax(260px, 1.5fr) minmax(0, 2fr);
    align-items: flex-start;
}

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

.kv-value {
    color: var(--st-text);
    word-break: break-all;
}

/* Full-width category header inside kv-list */
.kv-category-header {
    grid-column: 1 / -1;
    margin: 8px 0 4px;
    padding: 4px 6px;
    border-radius: 4px;
    background: #3b3f52;
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-left: 4px solid #7ca9ff;
}

/* Hover feedback for collapsible category headers */
.kv-category-header {
    cursor: pointer;
    transition: background 0.15s ease, border-left-color 0.15s ease, transform 0.12s ease;
}

    .kv-category-header:hover {
        background: #4c526a;
        border-left-color: #9bc2ff;
        transform: translateX(2px);
    }

.empty-state {
    font-size: 12px;
    color: var(--st-muted);
    padding: 10px 0;
}

.hidden {
    display: none !important;
}

/* Export / settings */
.export-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

.export-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--st-muted);
}

.export-format-pill {
    font-size: 11px;
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid var(--st-border);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
}

.settings-list {
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-item-label {
    font-weight: 500;
}

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

.active-bookmark {
    border-color: var(--st-accent) !important;
    color: var(--st-accent) !important;
}

/* ---- Bookmark Star Styling ---- */
.bookmark-btn {
    font-size: 16px !important;
    cursor: pointer;
    color: rgba(255,255,255,0.45);
    transition: color 0.18s ease, transform 0.15s ease;
}

    .bookmark-btn:hover {
        color: #ffd700;
        transform: scale(1.2);
    }

    /* ⭐ active bookmarked item */
    .bookmark-btn.marked {
        color: #ffd700 !important;
        text-shadow: 0 0 6px rgba(255,215,0,0.65);
        font-weight: bold;
    }

/* Status bar (used by app.js) */
.status-bar {
    font-size: 11px;
    color: var(--st-muted);
    margin-top: 4px;
}

    .status-bar.ok {
        color: var(--st-success);
    }

    .status-bar.error {
        color: var(--st-danger);
    }

    .status-bar.info {
        color: var(--st-primary);
    }

.advanced-filters {
    padding: 6px 9px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(5, 11, 20, 0.9);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* --- Unified styling for <select> elements across app --- */
select.input,
select {
    background: #1c1f27;
    color: #e5e5e5;
    border: 1px solid #3a3f4b;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

    /* Hover */
    select:hover {
        border-color: #6c9bff;
    }

    /* Focus */
    select:focus {
        border-color: #82b3ff;
        box-shadow: 0 0 0 3px rgba(130, 179, 255, 0.25);
    }

    /* Disabled styling */
    select:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* Dropdown option styling */
    select option {
        background: #1c1f27;
        color: #e5e5e5;
    }

/* --- Compact filter visual alignment --- */
.filter-compact {
    height: 30px !important;
    line-height: 30px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 6px;
}

    .filter-compact.select,
    .filter-compact[type="select"],
    .filter-compact select {
        appearance: none;
        -webkit-appearance: none;
    }

/* Ensure buttons with this class match input look */
button.filter-compact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px !important;
    padding: 0 10px;
    border-radius: 6px;
}

/* Slight hover consistency */
.filter-compact:hover {
    background-color: rgba(255,255,255,0.08);
    cursor: pointer;
}

/* Optional: subtle border standardization */
.filter-compact {
    border: 1px solid rgba(255,255,255,0.2);
}

/* ---- Index Summary: match Settings-list typography ---- */
#dashboard-summary {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 12px;
    line-height: 1.6;
    color: var(--st-text);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    #dashboard-summary .metric-row {
        font-weight: 400;
    }

    #dashboard-summary strong {
        font-weight: 600;
    }

    #dashboard-summary hr {
        margin: 4px 0;
        border: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        opacity: 0.6;
    }

.timeline-busy {
    position: relative;
}

    .timeline-busy .timeline-busy-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.95rem;
        font-weight: 500;
        background: rgba(8, 24, 48, 0.75);
        color: #fff;
        z-index: 5;
        pointer-events: none;
    }

/* --- SearchTrace modal --- */
.st-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

    .st-modal-overlay.hidden {
        display: none;
    }

.st-modal {
    background: var(--panel-bg, #1e1e1e);
    color: var(--text-main, #e6e6e6);
    border-radius: 8px;
    width: 420px;
    max-width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255,255,255,0.08);
}

.st-modal-header {
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient( to bottom, rgba(255, 190, 50, 0.15), rgba(255, 190, 50, 0.05) );
}

.st-modal-body {
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-line;
}

.st-modal-footer {
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* Responsive */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        flex-direction: row;
        overflow-x: auto;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--st-border);
    }

    .brand {
        min-width: 220px;
    }

    .sidebar-section-label,
    .sidebar-footer {
        display: none;
    }

    .nav-list {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .nav-btn {
        white-space: nowrap;
    }
}
