﻿:root {
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --radius: 8px;
    --bg-page: #f5f7fa;
    --bg-card: #ffffff;
    --text-primary: #142033;
    --text-secondary: #5c6d83;
    --text-muted: #8090a6;
    --primary: #1f6fd6;
    --primary-press: #1859ac;
    --border: #d4deea;
    --danger: #d92d20;
    --success: #1f8f56;
    --success-bg: #f3fbf6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.4;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 64px;
    padding: var(--space-1) 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
    background: #154a95;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.topbar-kicker {
    font-size: 12px;
    opacity: 0.9;
}

.topbar-title {
    font-size: 20px;
    font-weight: 600;
}

.topbar-user-menu {
    position: relative;
}

.user-menu-btn {
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

#user-menu-name {
    font-weight: 600;
}

#user-menu-role {
    opacity: 0.85;
}

.user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 148px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
}

.user-menu-panel.open {
    display: block;
}

.menu-item {
    width: 100%;
    min-height: 40px;
    border-radius: 6px;
    border: 1px solid #efb1ac;
    background: #fff5f4;
    color: var(--danger);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.menu-link {
    width: 100%;
    min-height: 40px;
    border-radius: 6px;
    border: 1px solid #b7c7dc;
    background: #f9fbff;
    color: #2a446a;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.main {
    width: min(1320px, 100%);
    margin: 0 auto;
    padding: var(--space-3) 24px;
    display: grid;
    gap: var(--space-3);
}

.meta-row {
    display: none;
}

.welcome-text {
    font-size: 12px;
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
}

.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: var(--space-2);
    min-height: 92px;
}

.metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: #11387b;
}

.controls-panel,
.list-panel,
.pagination {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: var(--space-2);
}

.search-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: var(--space-1);
}

.search-input-wrap {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 12px;
}

.search-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 214, 0.16);
}

.search-icon {
    color: var(--text-muted);
    font-size: 14px;
}

#search {
    width: 100%;
    min-height: 46px;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
}

.clear-search {
    min-width: 32px;
    min-height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.secondary-row {
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
}

.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    font-size: 14px;
    color: var(--text-secondary);
}

.checkbox-wrap input {
    width: 18px;
    height: 18px;
}

.tooltip {
    font-size: 12px;
    color: var(--text-muted);
}

.secondary-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.select-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.select-wrap select {
    min-height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 0 10px;
    background: #fff;
    color: var(--text-primary);
}

.btn {
    min-height: 48px;
    min-width: 48px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:active,
.card-action:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-press);
}

.btn-secondary {
    border-color: #b7c7dc;
    color: #2a446a;
    background: #f9fbff;
}

.btn-secondary:hover:not(:disabled) {
    background: #edf3fc;
}

.btn:disabled {
    cursor: not-allowed;
    color: #9aa8ba;
    border-color: #dde4ed;
    background: #f3f5f8;
}

.list-state {
    min-height: 120px;
    border: 1px dashed #cfdaea;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: var(--space-2);
    text-align: center;
}

.list-state.error {
    color: var(--danger);
}

.list-state.hidden {
    display: none;
}

.card-list {
    display: none;
    gap: var(--space-2);
}

.card-list.active {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.user-card {
    border: 1px solid #d8e2ef;
    border-radius: var(--radius);
    padding: 14px;
    display: grid;
    gap: 8px;
    background: #fff;
}

.user-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
}

.status-badge {
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-active {
    color: var(--success);
    background: var(--success-bg);
    border: 1px solid #88d8ab;
}

.status-inactive {
    color: #667387;
    background: #eff3f8;
    border: 1px solid #cad3df;
}

.user-id-row {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
}

.id-copy-btn {
    border: none;
    background: transparent;
    color: #1d3760;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.id-copy-btn:hover {
    text-decoration: underline;
}

.copy-tip {
    color: var(--text-muted);
    font-size: 12px;
}

.user-meta {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    font-size: 14px;
}

.user-meta-item {
    color: var(--text-secondary);
}

.user-meta-item:last-child {
    font-size: 12px;
    color: var(--text-muted);
}

.user-meta-item strong {
    color: var(--text-primary);
    font-weight: 500;
}

.card-actions {
    display: flex;
    gap: var(--space-1);
    margin-top: 4px;
    justify-content: flex-end;
}

.card-action {
    min-height: 40px;
    min-width: 96px;
    border-radius: var(--radius);
    border: 1px solid #b7c7dc;
    background: #fff;
    color: #2a446a;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 0 14px;
}

.card-action.delete {
    border-color: #efb1ac;
    color: var(--danger);
}

.card-action:hover {
    background: #edf3fc;
}

.card-action.delete:hover {
    background: #fff5f4;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
}

.page-indicator {
    color: var(--text-secondary);
    font-size: 14px;
    min-width: 90px;
    text-align: center;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-2);
    background: rgba(15, 25, 40, 0.55);
    z-index: 60;
}

.modal-content {
    width: min(900px, 100%);
    max-height: 88vh;
    overflow-y: auto;
    border-radius: 10px;
    background: #fff;
    padding: var(--space-2);
    position: relative;
}

.close {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: #4c5f79;
    font-size: 28px;
    cursor: pointer;
}

.modal-content h2 {
    font-size: 18px;
    margin-bottom: var(--space-1);
}

.modal-content p {
    margin-bottom: 10px;
    font-size: 14px;
}

.modal-content pre {
    background: #f4f7fb;
    border: 1px solid #dce3ee;
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 12px;
    font-size: 12px;
    overflow-x: auto;
}

.loading .btn-secondary,
.loading .btn-primary {
    pointer-events: none;
    opacity: 0.7;
}

.loading #refresh-btn::after {
    content: "";
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid #aac1e3;
    border-top-color: #2a446a;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1024px) {
    .main {
        width: min(900px, 100%);
        padding: var(--space-2);
        gap: var(--space-2);
    }

    .card-list.active {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 12px;
        gap: 12px;
    }

    .topbar {
        min-height: 56px;
        padding: 8px 12px;
        flex-wrap: wrap;
    }

    .topbar-title {
        font-size: 14px;
    }

    .topbar-kicker {
        font-size: 11px;
    }

    .meta-row {
        display: block;
    }

    .topbar-user-menu {
        width: 100%;
    }

    .user-menu-btn {
        width: 100%;
        justify-content: center;
    }

    .search-row {
        grid-template-columns: 1fr;
    }

    .secondary-row {
        flex-direction: column;
        align-items: stretch;
    }

    .secondary-actions {
        width: 100%;
        justify-content: space-between;
    }

    .select-wrap {
        flex: 1;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-1);
    }

    .card-list.active {
        grid-template-columns: 1fr;
        gap: var(--space-1);
    }

    .user-meta {
        grid-template-columns: 1fr;
    }

    .card-actions {
        justify-content: stretch;
    }

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

    .pagination {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
    }

    .pagination .btn {
        padding: 0 8px;
    }
}
