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

:root {
    --bg: #0d1117;
    --bg2: #161b22;
    --bg3: #21262d;
    --fg: #c9d1d9;
    --fg-dim: #8b949e;
    --fg-muted: #484f58;
    --green: #3fb950;
    --green-dim: rgba(63, 185, 80, 0.15);
    --red: #f85149;
    --red-dim: rgba(248, 81, 73, 0.15);
    --yellow: #d29922;
    --yellow-dim: rgba(210, 153, 34, 0.15);
    --blue: #58a6ff;
    --blue-dim: rgba(88, 166, 255, 0.15);
    --border: #30363d;
    --border-light: #3d444d;
    --radius: 8px;
    --radius-sm: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--bg);
    color: var(--fg);
    font-size: 14px;
    line-height: 1.5;
}

/* Login */
#login-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at center, #161b22 0%, #0d1117 70%);
}

.login-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 48px 40px;
    text-align: center;
    max-width: 360px;
}

.login-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--blue);
}

.login-box h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-box .subtitle {
    color: var(--fg-dim);
    margin-bottom: 32px;
}

.btn-login {
    display: inline-block;
    background: var(--blue);
    color: #fff;
    padding: 10px 24px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: opacity 0.15s;
}

.btn-login:hover { opacity: 0.85; }

/* Header */
header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    flex-shrink: 0;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: -0.5px;
}

.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 auto;
}

.search-wrap {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--fg-muted);
    pointer-events: none;
}

#search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

#search:focus {
    border-color: var(--blue);
}

#search::placeholder {
    color: var(--fg-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#filter-department {
    padding: 6px 10px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.user-email {
    color: var(--fg-dim);
    font-size: 13px;
}

/* User count */
.user-count {
    padding: 8px 24px;
    color: var(--fg-dim);
    font-size: 13px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 80px 24px;
    color: var(--fg-dim);
}

.loading.hidden { display: none; }

/* User grid */
.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    padding: 0 24px 24px;
}

/* User card */
.user-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.user-card:hover {
    border-color: var(--border-light);
    background: var(--bg3);
}

.user-card .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg3);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--blue);
    overflow: hidden;
}

.user-card .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-card .info {
    flex: 1;
    min-width: 0;
}

.user-card .name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card .title-text {
    color: var(--fg-dim);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card .meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.user-card .username {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--fg-muted);
}

.badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.badge-dept {
    background: var(--blue-dim);
    color: var(--blue);
}

.badge-admin {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.badge-suspended {
    background: var(--red-dim);
    color: var(--red);
}

.badge-2sv {
    background: var(--green-dim);
    color: var(--green);
}

.device-badges {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.badge-device {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--bg3);
    color: var(--fg-dim);
    text-decoration: none;
    transition: color 0.15s;
}

.badge-device:hover {
    color: var(--blue);
}

/* Detail panel */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
}

.detail-overlay.hidden { display: none; }

.user-detail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 90vw;
    background: var(--bg2);
    border-left: 1px solid var(--border);
    z-index: 201;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.2s ease;
}

.user-detail.visible {
    transform: translateX(0);
}

.user-detail.hidden {
    display: none;
}

.detail-header {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.detail-header .avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg3);
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: var(--blue);
    overflow: hidden;
}

.detail-header .avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-header .detail-name {
    font-size: 20px;
    font-weight: 700;
}

.detail-header .detail-title {
    color: var(--fg-dim);
    font-size: 14px;
    margin-top: 2px;
}

.detail-header .detail-badges {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
}

.detail-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--fg-dim);
    font-size: 24px;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.detail-close:hover { color: var(--fg); background: var(--bg3); }

.detail-section {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.detail-section h4 {
    color: var(--fg-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 4px 0;
}

.detail-row .label {
    color: var(--fg-dim);
    font-size: 13px;
    flex-shrink: 0;
}

.detail-row .value {
    font-size: 13px;
    text-align: right;
    word-break: break-all;
}

.detail-row .value a {
    color: var(--blue);
    text-decoration: none;
}

.detail-row .value a:hover {
    text-decoration: underline;
}

.detail-row .value.mono {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 12px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--fg-dim);
}

.empty-state .empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--fg-muted);
}

/* Copy button */
.btn-copy {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--fg-dim);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    transition: color 0.15s, border-color 0.15s;
}

.btn-copy:hover { color: var(--blue); border-color: var(--blue); }

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Card focus */
.user-card:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
    }

    .header-center {
        order: 3;
        max-width: 100%;
        flex-basis: 100%;
    }

    .header-right {
        margin-left: auto;
    }

    .user-email { display: none; }

    .user-grid {
        grid-template-columns: 1fr;
        padding: 0 16px 16px;
    }

    .user-count { padding: 8px 16px; }

    .user-detail { width: 100vw; max-width: 100vw; }
}
