:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-block { width: 100%; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

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

.card-header h2 { font-size: 18px; font-weight: 600; }

.navbar {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: white;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.nav-brand {
    font-size: 22px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-menu {
    display: flex;
    gap: 8px;
    list-style: none;
}

.nav-menu a {
    color: rgba(255,255,255,0.85);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-menu a:hover, .nav-menu a.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-user .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    cursor: pointer;
}

.nav-user .dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 48px;
    right: 0;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 8px 0;
    display: none;
    z-index: 100;
}

.dropdown:hover .dropdown-menu { display: block; }

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--gray-700);
    font-size: 14px;
}

.dropdown-menu a:hover { background: var(--gray-50); color: var(--primary); }

.hero {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #8b5cf6 100%);
    color: white;
    padding: 80px 0;
    text-align: center;
}

.hero h1 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
}

.hero p {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 32px;
}

.hero .btn-group {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.hero .btn-primary { background: white; color: var(--primary); }
.hero .btn-primary:hover { background: var(--gray-100); }
.hero .btn-ghost { background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.4); }
.hero .btn-ghost:hover { background: rgba(255,255,255,0.3); }

.stats-bar {
    background: white;
    padding: 24px 0;
    box-shadow: var(--shadow);
    margin-top: -40px;
    position: relative;
    border-radius: var(--radius);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    text-align: center;
}

.stat-item .number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-item .label {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    margin-top: 24px;
}

.sidebar .card { margin-bottom: 20px; }
.sidebar h3 { font-size: 16px; margin-bottom: 12px; font-weight: 600; }

.board-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.board-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary);
    transition: all 0.2s;
}

.board-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.board-card .board-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.board-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
}

.board-card p {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
    line-height: 1.5;
}

.board-card .board-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--gray-500);
}

.thread-list .thread-item {
    display: flex;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.thread-list .thread-item:last-child { border-bottom: none; }

.thread-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
}

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

.thread-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.thread-title:hover { color: var(--primary); }

.thread-meta {
    font-size: 13px;
    color: var(--gray-500);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.thread-meta .tag {
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.thread-stats {
    display: flex;
    gap: 16px;
    align-items: center;
    color: var(--gray-500);
    font-size: 13px;
    flex-shrink: 0;
}

.thread-stats .stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: white;
    border: 1px solid var(--border);
}

.pagination .current {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.footer {
    background: var(--gray-800);
    color: var(--gray-400);
    padding: 40px 0 24px;
    margin-top: 60px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 32px;
}

.footer h4 {
    color: white;
    font-size: 16px;
    margin-bottom: 16px;
}

.footer ul { list-style: none; }
.footer ul li { margin-bottom: 10px; }
.footer ul li a { color: var(--gray-400); font-size: 14px; }
.footer ul li a:hover { color: white; }

.footer-bottom {
    border-top: 1px solid var(--gray-700);
    padding-top: 24px;
    text-align: center;
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-top { background: var(--danger); color: white; }
.badge-essence { background: var(--warning); color: white; }
.badge-closed { background: var(--gray-400); color: white; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e40af, #3b82f6, #8b5cf6);
    padding: 20px;
}

.auth-box {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-box h2 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text);
}

.auth-box .subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 28px;
}

.auth-box .auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--gray-500);
}

.chat-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: calc(100vh - 120px);
    margin-top: 20px;
    gap: 0;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.chat-sidebar {
    background: var(--gray-50);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.chat-sidebar h3 {
    padding: 16px;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
}

.chat-room-item {
    display: block;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.chat-room-item:hover {
    background: var(--gray-100);
}

.chat-room-item.active {
    background: var(--primary);
    color: white;
    border-left-color: var(--primary-dark);
}

.chat-room-item .room-name {
    font-weight: 600;
    font-size: 14px;
}

.chat-room-item .room-desc {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 2px;
}

.chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.chat-message .msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-message .msg-body { max-width: 70%; }

.chat-message .msg-meta {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.chat-message .msg-content {
    background: var(--gray-100);
    padding: 10px 14px;
    border-radius: 12px;
    word-break: break-word;
}

.chat-message.self { flex-direction: row-reverse; }
.chat-message.self .msg-body { text-align: right; }
.chat-message.self .msg-content {
    background: var(--primary);
    color: white;
}

.chat-input {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

.chat-input textarea {
    flex: 1;
    resize: none;
    height: 40px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
}

.chat-input textarea:focus { border-color: var(--primary); }

.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: var(--gray-800);
    color: white;
    padding: 20px 0;
}

.admin-sidebar h2 {
    padding: 0 20px 20px;
    font-size: 18px;
    border-bottom: 1px solid var(--gray-700);
}

.admin-sidebar ul { list-style: none; }
.admin-sidebar ul li a {
    display: block;
    padding: 12px 20px;
    color: var(--gray-300);
    transition: all 0.2s;
}

.admin-sidebar ul li a:hover,
.admin-sidebar ul li a.active {
    background: var(--primary);
    color: white;
}

.admin-content {
    padding: 24px;
    background: var(--bg);
}

.admin-content h1 {
    font-size: 24px;
    margin-bottom: 20px;
}

.admin-table {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.admin-table table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-600);
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stat-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.admin-stat-card .num {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.admin-stat-card .label {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .nav-menu { display: none; }
    .hero h1 { font-size: 32px; }
    .hero p { font-size: 16px; }
    .main-layout { grid-template-columns: 1fr; }
    .board-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: 1fr; }
    .chat-container { grid-template-columns: 1fr; }
    .chat-sidebar { display: none; }
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { display: none; }
}
