* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
a { color: inherit; }

.admin-body {
    background: #f0f2f5;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    margin: 0;
    color: #333;
}
.admin-header {
    background: #001529;
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.admin-header .brand { font-size: 18px; font-weight: 600; }
.admin-header a { color: #fff; text-decoration: none; margin-left: 20px; }
.admin-header a:hover { color: #40a9ff; }

.admin-layout { display: flex; min-height: calc(100vh - 56px); }
.admin-side {
    width: 200px;
    background: #001529;
    padding-top: 20px;
}
.admin-side a {
    display: block;
    padding: 12px 24px;
    color: #ccc;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.admin-side a:hover, .admin-side a.active {
    background: #1890ff22;
    color: #fff;
    border-left-color: #1890ff;
}
.admin-main { flex: 1; padding: 24px; }
.admin-card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    margin-bottom: 20px;
}
.admin-card h2 { margin-top: 0; }

.form-row { margin-bottom: 16px; }
.form-row label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #555;
}
.form-row input[type=text],
.form-row input[type=password],
.form-row input[type=number],
.form-row input[type=url],
.form-row textarea,
.form-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
    border-color: #40a9ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24,144,255,.2);
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 12px; color: #999; margin-top: 4px; }

.btn-primary, .btn-danger, .btn-default {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary { background: #1890ff; color: #fff; border-color: #1890ff; }
.btn-primary:hover { background: #40a9ff; }
.btn-danger { background: #ff4d4f; color: #fff; border-color: #ff4d4f; }
.btn-danger:hover { background: #ff7875; }
.btn-default { background: #fff; color: #333; border-color: #d9d9d9; }
.btn-default:hover { border-color: #40a9ff; color: #40a9ff; }

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
table.admin-table th, table.admin-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    font-size: 14px;
}
table.admin-table th { background: #fafafa; font-weight: 600; color: #555; }
table.admin-table tr:hover { background: #fafafa; }

.alert {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #52c41a; }
.alert-error   { background: #fff2f0; border: 1px solid #ffccc7; color: #ff4d4f; }
.alert-info    { background: #e6f7ff; border: 1px solid #91d5ff; color: #1890ff; }

.color-swatch {
    display: inline-block;
    width: 20px; height: 20px;
    border-radius: 3px;
    border: 1px solid #ddd;
    vertical-align: middle;
    margin-right: 6px;
}

.cs-rich-preview {
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    background: #fafafa;
    font-size: 13px;
    line-height: 1.6;
    white-space: normal;
}
.cs-rich-img {
    display: block;
    max-width: 220px;
    height: auto;
    border-radius: 6px;
    margin: 6px 0;
}
.rich-source {
    display: none;
}
.rich-editor {
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}
.rich-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}
.rich-toolbar input[type=text] {
    flex: 1;
    min-width: 260px;
    padding: 7px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 13px;
}
.rich-color {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    font-size: 13px;
    font-weight: 400 !important;
}
.rich-color input {
    width: 42px;
    height: 30px;
    padding: 0;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    background: #fff;
}
.rich-tool-btn,
.rich-file-btn {
    padding: 5px 10px;
    font-size: 13px;
}
.rich-file-btn {
    margin: 0;
    position: relative;
    overflow: hidden;
}
.rich-file-btn input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.rich-editbox {
    min-height: 150px;
    padding: 12px;
    outline: none;
    font-size: 14px;
    line-height: 1.7;
}
.rich-editbox:empty::before {
    content: "在这里输入自动客服话术";
    color: #aaa;
}
.rich-editbox .cs-rich-img {
    max-width: 260px;
}
.rich-code-preview {
    white-space: pre-wrap;
    word-break: break-all;
    background: #fafafa;
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    padding: 8px 10px;
    color: #666;
    font-size: 12px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-box { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.stat-box .num { font-size: 28px; font-weight: 600; color: #1890ff; }
.stat-box .lbl { color: #888; font-size: 13px; margin-top: 4px; }

.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    margin: 0;
}
.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 10px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-card h1 { text-align: center; margin-top: 0; color: #333; }
.login-card .btn-primary { width: 100%; padding: 10px; font-size: 15px; }

@media (max-width: 720px) {
    .admin-layout { flex-direction: column; }
    .admin-side { width: 100%; padding: 0; display: flex; overflow-x: auto; }
    .admin-side a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; padding: 10px 16px; }
    .admin-side a.active { border-left: none; border-bottom-color: #1890ff; }
}
