body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background: #0f1115;
    color: #e6e6e6;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #161922;
    border-bottom: 1px solid #262b36;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar-links { display: flex; align-items: center; gap: 16px; }
.nav-link { color: #7aa2ff; text-decoration: none; font-size: 13px; }
.logout-link { color: #9aa4b2; text-decoration: none; font-size: 13px; }

.flash { background: #1d3b2a; color: #8fe3ab; padding: 10px 24px; }

.status-panel {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 24px;
    background: #141821;
}
.counts span { margin-left: 16px; color: #c8ced8; }

.controls { padding: 16px 24px; background: #12151c; border-bottom: 1px solid #262b36; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px 16px;
    margin-bottom: 12px;
}
.form-grid label { display: flex; flex-direction: column; font-size: 12px; color: #9aa4b2; gap: 4px; }
.form-grid input[type="number"] {
    background: #1b1f29;
    border: 1px solid #2c3240;
    color: #e6e6e6;
    padding: 6px 8px;
    border-radius: 4px;
}
.checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; }

button {
    background: #3a6df0;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}
button:disabled { background: #2a2f3a; color: #6b7280; cursor: not-allowed; }
.stop-form { display: inline-block; margin-left: 8px; }
.stop-form button { background: #c94545; }

.log-panel { padding: 16px 24px; }
.log-panel h2 { font-size: 14px; color: #9aa4b2; text-transform: uppercase; letter-spacing: 0.05em; }
.log-panel pre {
    background: #0b0d11;
    border: 1px solid #262b36;
    padding: 12px;
    max-height: 220px;
    overflow: auto;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.tabs { padding: 16px 24px 48px; }
.tab-buttons { display: flex; gap: 4px; margin-bottom: 8px; }
.tab-btn {
    background: #1b1f29;
    color: #c8ced8;
    border: 1px solid #2c3240;
    padding: 8px 16px;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    font-size: 13px;
}
.tab-btn.active { background: #3a6df0; color: #fff; border-color: #3a6df0; }

.tab-toolbar { margin-bottom: 8px; }
#filterInput {
    width: 100%;
    max-width: 400px;
    padding: 8px;
    background: #1b1f29;
    border: 1px solid #2c3240;
    color: #e6e6e6;
    border-radius: 4px;
}

.filter-panel {
    background: #12151c;
    border: 1px solid #262b36;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 12px;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px 16px;
    margin-bottom: 10px;
}
.filter-grid label { display: flex; flex-direction: column; font-size: 12px; color: #9aa4b2; gap: 4px; }
.filter-grid input,
.filter-grid select {
    background: #1b1f29;
    border: 1px solid #2c3240;
    color: #e6e6e6;
    padding: 6px 8px;
    border-radius: 4px;
}
.filter-actions { display: flex; gap: 8px; }
.filter-actions button.secondary,
button.secondary { background: #2a2f3a; color: #c8ced8; }

.tab-content { display: none; }
.tab-content.active { display: block; }
.download-link { display: inline-block; margin-bottom: 8px; color: #7aa2ff; font-size: 13px; }

table.sortable { border-collapse: collapse; width: 100%; font-size: 13px; }
table.sortable th,
table.sortable td { border: 1px solid #262b36; padding: 6px 8px; text-align: left; white-space: nowrap; }
table.sortable th { background: #1b1f29; cursor: pointer; user-select: none; position: sticky; top: 0; }
table.sortable th.sort-asc::after { content: " \25B2"; }
table.sortable th.sort-desc::after { content: " \25BC"; }
table.sortable tbody tr:nth-child(even) { background: #141821; }

.muted { color: #7a8494; }

.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: #0f1115; }
.login-form { background: #161922; padding: 32px; border-radius: 8px; width: 280px; }
.login-form h1 { font-size: 18px; margin-top: 0; }
.login-form label { display: block; margin-bottom: 16px; color: #9aa4b2; font-size: 13px; }
.login-form input {
    width: 100%;
    padding: 8px;
    margin-top: 6px;
    background: #1b1f29;
    border: 1px solid #2c3240;
    color: #e6e6e6;
    border-radius: 4px;
    box-sizing: border-box;
}
.error { color: #ff8080; }

/* --- Admin pages (users, audit log) --- */
.nav-user { color: #c8ced8; font-size: 13px; }

.admin-section {
    padding: 16px 24px;
    border-bottom: 1px solid #262b36;
}
.admin-section h2 { font-size: 15px; margin-top: 0; }
.admin-form .form-grid,
.admin-form .filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px 16px;
    margin-bottom: 12px;
}
.admin-form label { display: flex; flex-direction: column; font-size: 12px; color: #9aa4b2; gap: 4px; }
.admin-form input,
.admin-form select {
    background: #1b1f29;
    border: 1px solid #2c3240;
    color: #e6e6e6;
    padding: 6px 8px;
    border-radius: 4px;
}

.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; margin-top: 8px; }
.admin-table th, .admin-table td { border: 1px solid #262b36; padding: 6px 8px; text-align: left; vertical-align: middle; }
.admin-table th { background: #1b1f29; }
.admin-table tbody tr:nth-child(even) { background: #141821; }

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.role-admin { background: #3a1f5c; color: #d9b8ff; }
.role-viewer { background: #1f3a5c; color: #b8d4ff; }

.status-active { color: #8fe3ab; }
.status-inactive { color: #7a8494; }

.action-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    background: #1b1f29;
    color: #c8ced8;
}

.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
.small-select { padding: 4px 6px; font-size: 12px; background: #1b1f29; border: 1px solid #2c3240; color: #e6e6e6; border-radius: 4px; }
button.small { padding: 4px 10px; font-size: 12px; }

.button-link {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 5px;
    font-size: 14px;
    text-decoration: none;
    background: #2a2f3a;
    color: #c8ced8;
}

.details-cell { font-family: monospace; font-size: 12px; max-width: 420px; overflow-wrap: break-word; }

.pagination { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
.pagination a { color: #7aa2ff; text-decoration: none; }

.run-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: #12151c;
    border-bottom: 1px solid #262b36;
}
.run-selector label { font-size: 12px; color: #9aa4b2; }
.run-selector select {
    flex: 1;
    max-width: 600px;
    background: #1b1f29;
    border: 1px solid #2c3240;
    color: #e6e6e6;
    padding: 6px 8px;
    border-radius: 4px;
}

button.danger { background: #c94545 !important; color: #fff; }
button.danger:hover { background: #b23a3a !important; }
#saveDefaultsMsg { font-size: 12px; }

.column-panel-wrap { margin-bottom: 12px; }
.columns-panel {
    background: #12151c;
    border: 1px solid #262b36;
    border-radius: 6px;
    padding: 12px 16px;
    margin-top: 8px;
}
.columns-list {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 10px;
    border: 1px solid #262b36;
    border-radius: 4px;
}
.columns-list-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    border-bottom: 1px solid #1b1f29;
}
.columns-list-row:last-child { border-bottom: none; }
.columns-list-row:nth-child(even) { background: #141821; }
.columns-list-label { flex: 1; font-size: 13px; color: #e6e6e6; }
.columns-list-row button.small { padding: 2px 8px; font-size: 11px; }
#saveColumnsMsg { font-size: 12px; }

.saved-views-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #12151c;
    border: 1px solid #262b36;
    border-radius: 6px;
    margin-bottom: 12px;
}
.saved-views-wrap label { display: flex; flex-direction: column; font-size: 12px; color: #9aa4b2; gap: 4px; }
.saved-views-wrap select {
    background: #1b1f29;
    border: 1px solid #2c3240;
    color: #e6e6e6;
    padding: 6px 8px;
    border-radius: 4px;
    min-width: 220px;
}
