/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1a56db;
    --primary-hover: #1648b5;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --success: #059669;
    --error: #dc2626;
    --warning: #d97706;
    --radius: 8px;
}

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

/* --- Navbar --- */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.nav-brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    white-space: nowrap;
}

.nav-links { display: flex; gap: 4px; }

.nav-link {
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: #eff6ff; color: var(--primary); }

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}
.user-name { color: var(--text); font-weight: 500; }
.logout-link { color: var(--error) !important; }

/* --- Container --- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
    flex: 1;
}

/* --- Login --- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.login-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 22px; margin-bottom: 4px; }
.login-header p { color: var(--text-muted); font-size: 14px; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

input[type="email"],
input[type="password"],
input[type="text"],
.search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.15s;
    outline: none;
}
input:focus, .search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-sso {
    width: 100%;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
}
.btn-sso:hover { background: var(--bg); border-color: #d1d5db; }

.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}
.divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}
.divider span {
    background: var(--surface);
    padding: 0 12px;
    position: relative;
    color: var(--text-muted);
    font-size: 13px;
}

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}
.page-header h1 { font-size: 22px; }

/* --- Stats --- */
.stats-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.stat-value { font-weight: 700; font-size: 18px; color: var(--primary); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Toolbar --- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 600px;
}
.search-input { flex: 1; }
.result-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    background: #f9fafb;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f9fafb; }

.sort-link {
    text-decoration: none;
    color: inherit;
}
.sort-link:hover { color: var(--primary); }
.sort-link.active { color: var(--primary); }

.nowrap { white-space: nowrap; }
.empty-state { text-align: center; padding: 40px !important; color: var(--text-muted); }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}
.badge-admin { background: #eff6ff; color: var(--primary); }
.badge-viewer { background: #f0fdf4; color: var(--success); }
.badge-running { background: #fffbeb; color: var(--warning); }
.badge-complete { background: #f0fdf4; color: var(--success); }

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}
.page-info { font-size: 14px; color: var(--text-muted); }

/* --- Info Box --- */
.info-box {
    margin-top: 24px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 20px;
}
.info-box h3 { font-size: 14px; margin-bottom: 6px; color: var(--primary); }
.info-box p { font-size: 13px; color: #1e40af; }

.inline-form { display: inline; }

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .navbar { padding: 0 12px; gap: 12px; }
    .container { padding: 16px; }
    .stats-bar { gap: 8px; }
    .stat { padding: 6px 10px; }
    .stat-value { font-size: 14px; }
    .search-form { max-width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
