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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #232734;
    --border: #2e3348;
    --text: #e1e4ed;
    --text-dim: #8b8fa3;
    --primary: #5b8def;
    --primary-hover: #4a7de0;
    --danger: #ef5b5b;
    --warning: #efb45b;
    --success: #5bef8b;
    --info: #5bc0ef;
    --trace: #8b8fa3;
    --debug: #a78bfa;
    --radius: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

/* Auth */
.auth-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 380px;
    text-align: center;
    box-shadow: var(--shadow);
}
.auth-card h1 { margin-bottom: 0.5rem; font-size: 1.5rem; }
.auth-card p { color: var(--text-dim); margin-bottom: 1.5rem; font-size: 0.9rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.75rem; }

/* Inputs & Buttons */
input, select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--primary); }
input::placeholder { color: var(--text-dim); }

button {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
button:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text); }
button.secondary:hover { background: var(--border); }

.error { color: var(--danger); font-size: 0.85rem; }
.hidden { display: none !important; }

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
header h1 { font-size: 1.25rem; }
#logout-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim); font-size: 0.8rem; padding: 0.35rem 0.75rem; }

/* Filters */
.filters { padding: 1rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.filter-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-group label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.filter-group input, .filter-group select { min-width: 140px; }
#filter-search { min-width: 200px; }
.filter-actions { flex-direction: row; gap: 0.5rem; align-self: flex-end; }

/* Status */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}
#page-size-wrap { display: flex; align-items: center; gap: 0.4rem; }
#page-size { min-width: auto; padding: 0.25rem 0.4rem; font-size: 0.8rem; }

/* Table */
.table-wrap { padding: 0 1.5rem; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: var(--surface2);
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
.sort-icon { font-size: 0.65rem; }

tbody tr {
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}
tbody tr:hover { background: var(--surface2); }
td { padding: 0.5rem 0.75rem; vertical-align: top; }
td:nth-child(1) { white-space: nowrap; color: var(--text-dim); min-width: 160px; }
td:nth-child(2) { white-space: nowrap; font-weight: 500; min-width: 100px; }
td:nth-child(3) { white-space: nowrap; min-width: 80px; }
td:nth-child(4) {
    max-width: 600px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
}

/* Level badges */
.level { padding: 0.15rem 0.5rem; border-radius: 3px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.level-trace { background: rgba(139,143,163,0.15); color: var(--trace); }
.level-debug { background: rgba(167,139,250,0.15); color: var(--debug); }
.level-info { background: rgba(91,192,239,0.15); color: var(--info); }
.level-warning { background: rgba(239,180,91,0.15); color: var(--warning); }
.level-error { background: rgba(239,91,91,0.15); color: var(--danger); }
.level-fatal { background: rgba(239,91,91,0.3); color: #ff4444; }

#loading, #no-results { padding: 2rem; text-align: center; color: var(--text-dim); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
}
#page-info { font-size: 0.85rem; 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: 100;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 700px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}
.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.25rem; padding: 0.25rem 0.5rem; }
#modal-close:hover { color: var(--text); }
.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    font-size: 0.875rem;
    line-height: 1.6;
}
.detail-row { display: flex; margin-bottom: 0.75rem; }
.detail-label { width: 100px; color: var(--text-dim); font-weight: 600; flex-shrink: 0; }
.detail-value { flex: 1; word-break: break-all; }
.detail-message {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .filter-row { flex-direction: column; }
    .filter-group input, .filter-group select { min-width: 100%; }
    td:nth-child(4) { max-width: 200px; }
    .modal { width: 95vw; }
}
