* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f4f7fb;
    color: #2c3e50;
}

a {
    color: inherit;
    text-decoration: none;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    color: #cbd5e1;
    padding: 24px 18px;
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.brand-title {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.brand-sub {
    font-size: 12px;
    color: #94a3b8;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
}

.nav-link:hover,
.nav-link.danger:hover {
    background: rgba(59, 130, 246, 0.18);
    color: #fff;
}

.nav-link.danger {
    color: #fca5a5;
}

.main {
    flex: 1;
    padding: 24px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.topbar p {
    margin: 8px 0 0;
    color: #64748b;
}

.content {
    margin-top: 24px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card,
.panel,
.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.stat-card {
    padding: 20px;
}

.stat-card span {
    display: block;
    color: #64748b;
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 32px;
}

.panel {
    padding: 20px;
    margin-top: 20px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.toolbar-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

input,
select,
textarea,
.btn {
    border-radius: 10px;
    border: 1px solid #dbe3ee;
    padding: 10px 12px;
    font-size: 14px;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.btn {
    cursor: pointer;
    background: #fff;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: #2563eb;
    color: #fff;
}

.btn-light {
    background: #f8fafc;
}

.btn-danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.btn-block {
    width: 100%;
}

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

.table th,
.table td {
    padding: 12px 10px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: top;
}

.table-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.table-avatar-fallback {
    color: #64748b;
    font-size: 20px;
}

.badge {
    padding: 4px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 12px;
}

.badge-audit-pending {
    background: #fff7ed;
    color: #c2410c;
}

.badge-audit-approved {
    background: #ecfdf5;
    color: #047857;
}

.badge-audit-rejected {
    background: #fef2f2;
    color: #b91c1c;
}

.actions {
    display: flex;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-help {
    margin: 0;
    color: #64748b;
    font-size: 13px;
}

.field-full {
    grid-column: 1 / -1;
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
    margin-top: 30px;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #dbeafe, #f8fafc 55%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 28px;
}

.login-header h1 {
    margin: 0;
}

.login-header p,
.login-tip {
    color: #64748b;
}

.inline-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.upload-inline {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 12px 0;
}

.image-grid-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.image-grid-preview img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.ad-block {
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    margin-bottom: 14px;
    background: #f8fafc;
}

.ad-title {
    font-weight: 600;
    margin-bottom: 12px;
}

.ad-title span {
    color: #64748b;
    font-size: 12px;
    margin-left: 8px;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin: 14px 0;
}

.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
}

.alert-success {
    background: #ecfdf5;
    color: #047857;
}

.knowledge-toolbar-admin,
.knowledge-block-admin-head,
.knowledge-editor-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.knowledge-blocks-admin {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 14px;
}

.knowledge-block-admin {
    padding: 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.knowledge-block-admin select,
.knowledge-block-admin textarea {
    width: 100%;
    margin-top: 12px;
}

.knowledge-image-admin {
    width: 100%;
    max-width: 320px;
    margin-top: 12px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
}

.knowledge-editor-simple {
    min-height: 320px;
    padding: 18px;
    border: 1px solid #dbe3ee;
    border-radius: 16px;
    background: #fff;
    line-height: 1.8;
}

.knowledge-editor-simple h2,
.knowledge-editor-simple h3,
.knowledge-editor-simple p {
    margin: 0 0 12px;
}

.knowledge-editor-simple h2 {
    font-size: 28px;
}

.knowledge-editor-simple h3 {
    font-size: 22px;
}

.knowledge-editor-simple img {
    max-width: 100%;
    border-radius: 14px;
}

.knowledge-editor-quill {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
}

.knowledge-editor-quill .ql-toolbar.ql-snow {
    border-color: #dbe3ee;
}

.knowledge-editor-quill .ql-container.ql-snow {
    min-height: 420px;
    border-color: #dbe3ee;
    font-size: 15px;
}

/* 编辑器内图片自适应 */
.knowledge-editor-quill .ql-editor img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    margin: 8px 0;
}

/* 编辑器内段落行距 */
.knowledge-editor-quill .ql-editor p {
    margin-bottom: 10px;
    line-height: 1.8;
}

@media (max-width: 960px) {
    .admin-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .inline-grid {
        grid-template-columns: 1fr;
    }

    .upload-inline {
        flex-direction: column;
        align-items: stretch;
    }

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