/* ========== 基础 ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: #1f2937;
    background: #f3f4f6;
    line-height: 1.5;
}
.hidden { display: none !important; }
code { background: #e5e7eb; padding: 1px 6px; border-radius: 4px; font-family: Consolas, monospace; font-size: 12px; }

/* ========== 按钮 ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border: 1px solid transparent; border-radius: 6px;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: all 0.15s; gap: 6px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: #4f46e5; color: white; }
.btn-primary:hover:not(:disabled) { background: #4338ca; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: #059669; color: white; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-ghost { background: transparent; color: #374151; border-color: #d1d5db; }
.btn-ghost:hover { background: #f3f4f6; }
.btn-link { background: none; border: none; color: #4f46e5; padding: 4px 8px; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

/* ========== 登录页 ========== */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
}
.login-box {
    background: white; border-radius: 12px; padding: 40px; width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo {
    width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white; font-size: 28px; font-weight: bold; display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
}
.login-brand h1 { font-size: 20px; color: #111827; }
.subtitle { color: #6b7280; font-size: 13px; margin-top: 4px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; background: white; transition: border-color 0.15s;
    font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-error {
    background: #fef2f2; border: 1px solid #fecaca; color: #dc2626;
    padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px;
}
.login-tip { text-align: center; font-size: 12px; color: #9ca3af; margin-top: 16px; }

/* ========== 主布局 ========== */
.app-wrap { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
    width: 220px; background: #111827; color: #e5e7eb; display: flex; flex-direction: column;
    flex-shrink: 0;
}
.sidebar-brand {
    padding: 20px; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid #1f2937;
}
.sidebar-logo {
    width: 36px; height: 36px; border-radius: 8px; background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white; font-weight: bold; font-size: 18px; display: flex; align-items: center; justify-content: center;
}
.sidebar-brand span { font-weight: 600; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    color: #9ca3af; text-decoration: none; border-radius: 6px;
    font-size: 14px; transition: all 0.15s;
}
.sidebar-nav a:hover { background: #1f2937; color: white; }
.sidebar-nav a.active { background: #4f46e5; color: white; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px; border-top: 1px solid #1f2937; }
.admin-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.admin-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: #4f46e5;
    color: white; font-weight: bold; display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}
.admin-detail { flex: 1; min-width: 0; }
.admin-name { font-size: 13px; color: white; font-weight: 500; }
.admin-role { font-size: 11px; color: #6b7280; }

/* ========== 主区域 ========== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.main-header {
    height: 60px; background: white; border-bottom: 1px solid #e5e7eb;
    padding: 0 24px; display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.main-header h2 { font-size: 18px; color: #111827; font-weight: 600; }
.server-badge {
    background: #ecfdf5; color: #059669; padding: 4px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}
.main-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ========== 卡片 ========== */
.card {
    background: white; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px; margin-bottom: 20px;
}
.card-title {
    font-size: 15px; font-weight: 600; color: #111827; margin-bottom: 16px;
    padding-bottom: 12px; border-bottom: 1px solid #f3f4f6;
    display: flex; align-items: center; justify-content: space-between;
}

/* ========== 仪表盘统计卡 ========== */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: white; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid #4f46e5;
}
.stat-card.success { border-left-color: #059669; }
.stat-card.warning { border-left-color: #d97706; }
.stat-card.danger { border-left-color: #dc2626; }
.stat-label { font-size: 13px; color: #6b7280; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: #111827; }
.stat-sub { font-size: 12px; color: #9ca3af; margin-top: 4px; }

/* ========== 工具栏 ========== */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select {
    padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 13px; background: white;
}

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin-table th {
    background: #f9fafb; padding: 10px 12px; text-align: left; font-weight: 600;
    color: #374151; border-bottom: 1px solid #e5e7eb; white-space: nowrap;
}
table.admin-table td {
    padding: 10px 12px; border-bottom: 1px solid #f3f4f6; color: #374151;
}
table.admin-table tbody tr:hover { background: #f9fafb; }
table.admin-table .code-cell { font-family: Consolas, monospace; font-size: 12px; }

/* ========== 标签 ========== */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f3f4f6; color: #374151; }

/* ========== 分页 ========== */
.pagination {
    display: flex; justify-content: center; align-items: center; gap: 8px;
    padding: 16px 0; font-size: 13px;
}
.pagination button {
    padding: 4px 12px; border: 1px solid #d1d5db; background: white; border-radius: 6px;
    cursor: pointer; font-size: 13px;
}
.pagination button:hover:not(:disabled) { background: #f3f4f6; }
.pagination button.active { background: #4f46e5; color: white; border-color: #4f46e5; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== Toast ========== */
.toast {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
    background: #111827; color: white; padding: 12px 24px; border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 9999;
    font-size: 14px; max-width: 400px; text-align: center;
    animation: slideDown 0.2s ease;
}
.toast.error { background: #dc2626; }
.toast.success { background: #059669; }
@keyframes slideDown {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== 弹窗 ========== */
.modal { position: fixed; inset: 0; z-index: 9998; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-box {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: white; border-radius: 12px; padding: 24px; width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-title { font-size: 16px; font-weight: 600; color: #111827; margin-bottom: 12px; }
.modal-body { font-size: 14px; color: #374151; margin-bottom: 20px; line-height: 1.6; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ========== 表单 ========== */
.form-row textarea { min-height: 100px; resize: vertical; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* ========== 日志 ========== */
.log-container {
    background: #111827; border-radius: 8px; padding: 16px; font-family: Consolas, monospace;
    font-size: 12px; color: #d1d5db; max-height: 500px; overflow-y: auto;
    line-height: 1.7;
}
.log-line { padding: 2px 0; white-space: pre-wrap; word-break: break-all; }
.log-line.error { color: #fca5a5; }
.log-line.warn { color: #fcd34d; }
.log-line.info { color: #93c5fd; }

/* ========== 加载 ========== */
.loading {
    text-align: center; padding: 40px; color: #6b7280;
}
.loading::before {
    content: ''; display: inline-block; width: 20px; height: 20px;
    border: 2px solid #e5e7eb; border-top-color: #4f46e5; border-radius: 50%;
    animation: spin 0.8s linear infinite; margin-right: 10px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 40px; color: #9ca3af; font-size: 13px; }
