*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3347;
    --text: #e0e0e6;
    --text-dim: #8b8fa3;
    --accent: #6c8cff;
    --accent-hover: #8aa4ff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Controls */
.controls {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.control-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.control-row + .control-row { margin-top: 0.75rem; }

.control-group { display: flex; flex-direction: column; gap: 0.3rem; }
.control-group label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

.search-group { flex: 1; min-width: 300px; }
.search-row { display: flex; gap: 0.5rem; align-items: center; }
.search-row input[type="text"] { flex: 1; }

select, input[type="text"] {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 0.45rem 0.6rem;
    font-size: 0.875rem;
}

select:focus, input:focus { outline: none; border-color: var(--accent); }

button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
}

button:hover { background: var(--accent-hover); }

.checkbox-label {
    display: flex; align-items: center; gap: 0.3rem;
    font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; cursor: pointer;
}

/* Filters row */
#filters-row:empty { display: none; }
.filter-group { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-group label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

/* Results info */
.results-info {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead { background: var(--surface2); }

th, td {
    padding: 0.55rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

th {
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    color: var(--text-dim);
    position: relative;
}

th:hover { color: var(--text); }
th .sort-arrow { margin-left: 0.3rem; font-size: 0.7rem; }

tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: var(--surface2); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.pagination button {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination .page-info {
    font-size: 0.8rem;
    color: var(--text-dim);
}

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

.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: 90%; max-width: 700px; max-height: 80vh;
    display: flex; flex-direction: column;
}

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

.modal-header h2 { font-size: 1rem; }

.modal-close {
    background: none; color: var(--text-dim); font-size: 1.5rem;
    padding: 0; line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    font-size: 0.85rem;
}

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th { width: 30%; color: var(--accent); font-weight: 500; vertical-align: top; padding: 0.35rem 0.75rem 0.35rem 0; }
.detail-table td { padding: 0.35rem 0; word-break: break-word; white-space: normal; }
.detail-table tr + tr th, .detail-table tr + tr td { border-top: 1px solid var(--border); }

.nested { margin-left: 1rem; }
.nested-key { color: var(--accent); }

/* Loading */
.loading { text-align: center; padding: 2rem; color: var(--text-dim); }
