:root {
    --primary: #09BE4F;
    --primary-hover: #08A847;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #09BE4F;
    --bg: #EDEDED;
    --card-bg: #FFFFFF;
    --text: #1A1A1A;
    --text-secondary: #666666;
    --border: #D9D9D9;
    --success: #09BE4F;
    --danger: #ef4444;
    --warning: #f59e0b;
}

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

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

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 400px;
    max-width: 90vw;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary);
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    color: white;
    font-size: 18px;
}

.sidebar-menu {
    list-style: none;
    padding: 10px 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: var(--sidebar-active);
}

.sidebar-menu li a .icon {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar-menu li.menu-divider {
    padding: 16px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
}

/* Collapsible menu groups (手风琴式折叠) */
.sidebar-menu .menu-group {
    list-style: none;
}

.menu-group-header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.menu-group-header:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.menu-group-header .icon {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.menu-group-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.menu-arrow {
    font-size: 12px;
    opacity: 0.6;
    transition: transform 0.25s ease;
}

.menu-group.open > .menu-group-header .menu-arrow {
    transform: rotate(180deg);
}

.menu-group.open > .menu-group-header {
    color: #fff;
    background: rgba(255,255,255,0.04);
}

.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0,0,0,0.18);
}

.menu-group.open > .submenu {
    max-height: 500px;
}

.submenu li a {
    padding-left: 42px;
    font-size: 13px;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
}

.topbar {
    background: var(--card-bg);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.content {
    padding: 30px;
}

/* Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: bold;
    color: var(--primary);
}

.stat-card .stat-label {
    color: var(--text-secondary);
    margin-top: 5px;
    font-size: 14px;
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 16px;
}

.card-body {
    padding: 24px;
}

/* Table */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
}

table tr:hover {
    background: #f8fafc;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: var(--primary);
    color: white !important;
    border: 1px solid var(--primary);
}

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

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

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

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 12px;
    padding: 30px;
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Badge */
.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination .pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    transition: all .15s;
}

.pagination .pg-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination .pg-btn.current {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
    font-weight: 600;
    pointer-events: none;
}

.pagination .pg-info {
    margin-left: 12px;
    font-size: 12px;
    color: #999;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--success);
    color: white;
    border-radius: 8px;
    z-index: 9999;
    display: none;
    animation: slideIn 0.3s ease;
}

.toast.error { background: var(--danger); }
.toast.show { display: block; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar .search-input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 250px;
}

/* Button Group */
.btn-group {
    display: inline-flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.btn-group .btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
}

.btn-group .btn:last-child {
    border-right: none;
}

.btn-group .btn:hover {
    background: #f1f5f9;
    color: var(--text);
}

.btn-group .btn.active {
    background: var(--primary);
    color: white;
}

/* Avatar */
.user-nick-cell {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
    vertical-align: middle;
}

.user-avatar-empty {
    display: inline-block;
    width: 30px;
    flex-shrink: 0;
}
