* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; color: #333; background: #f0f2f5; overflow-x: hidden; }
a { color: #1890ff; text-decoration: none; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #175a86; color: #e8f5ff; position: fixed; left: 0; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 100; box-shadow: 2px 0 8px rgba(12,67,106,0.18); }
.sidebar-logo { height: 64px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: bold; color: #fff; background: #155985; border-bottom: 1px solid rgba(255,255,255,0.16); letter-spacing: 1px; }
.sidebar-menu { flex: 1; padding: 10px 0; overflow-y: auto; }
.menu-group { padding: 0; list-style: none; }
.menu-group-title { position: relative; padding: 14px 22px; font-size: 15px; color: #d8ecfb; cursor: pointer; transition: all .2s; display: flex; align-items: center; justify-content: space-between; user-select: none; border-left: 3px solid transparent; }
.menu-group-title:hover { color: #fff; background: #1f6698; }
.menu-group-title.expanded { color: #68b7ff; background: #22689d; border-left-color: #4da3ff; }
.menu-group-title .arrow { font-size: 10px; color: rgba(232,245,255,0.58); transition: transform .2s; display: inline-block; }
.menu-group-title.expanded .arrow { transform: rotate(180deg); }
.menu-group-items { overflow: hidden; transition: max-height .3s ease; max-height: 0; }
.menu-group-items.expanded { max-height: 500px; }
.menu-item { position: relative; padding: 12px 24px 12px 36px; cursor: pointer; transition: all .2s; display: block; color: #d9ecfb; font-size: 14px; border-left: 3px solid transparent; }
.menu-item:hover { color: #fff; background: #1f6698; }
.menu-item.active { color: #68b7ff; background: #22689d; border-left-color: #4da3ff; font-weight: 500; }
.main { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-width: 0; }
.header { height: 56px; background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.header-user { display: flex; align-items: center; gap: 12px; }
.header-user span { color: #666; }
.content { flex: 1; padding: 24px; min-width: 0; max-width: 100%; overflow-x: hidden; }

/* Login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-box { background: #fff; border-radius: 8px; padding: 40px; width: 400px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.login-box h2 { text-align: center; margin-bottom: 32px; color: #333; font-size: 24px; }

/* Form */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; color: #555; font-weight: 500; }
.form-control { width: 100%; height: 40px; padding: 0 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; transition: border-color .2s; }
.form-control:focus { outline: none; border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.2); }
select.form-control { appearance: auto; }
textarea.form-control { height: auto; padding: 8px 12px; resize: vertical; }

/* Buttons */
.btn { display: inline-block; padding: 8px 20px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; cursor: pointer; transition: all .2s; background: #fff; color: #333; line-height: 1.5; }
.btn:hover { border-color: #1890ff; color: #1890ff; }
.btn-primary { background: #1890ff; border-color: #1890ff; color: #fff; }
.btn-primary:hover { background: #40a9ff; border-color: #40a9ff; }
.btn-danger { color: #ff4d4f; border-color: #ff4d4f; }
.btn-danger:hover { background: #ff4d4f; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Table */
.table-wrap { background: #fff; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); overflow: hidden; max-width: 100%; }
.table-toolbar { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f0f0f0; }
.table-toolbar h3 { font-size: 16px; font-weight: 500; }
table { width: 100%; border-collapse: collapse; }
thead { background: #fafafa; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
th { font-weight: 500; color: #555; }
td { color: #333; }
tr:hover td { background: #fafafa; }

.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overflow-y: visible; position: relative; }
.table-scroll table { min-width: max-content; width: max-content; }
.freeze-table {
    --freeze-col-1: 80px;
    --freeze-col-2: 140px;
    --freeze-action: 160px;
}
.freeze-table th:nth-child(1),
.freeze-table td:nth-child(1) {
    position: sticky;
    left: 0;
    width: var(--freeze-col-1);
    min-width: var(--freeze-col-1);
    max-width: var(--freeze-col-1);
    z-index: 3;
    background: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
}
.freeze-table th:nth-child(2),
.freeze-table td:nth-child(2) {
    position: sticky;
    left: var(--freeze-col-1);
    width: var(--freeze-col-2);
    min-width: var(--freeze-col-2);
    max-width: var(--freeze-col-2);
    z-index: 3;
    background: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
}
.freeze-table th:last-child,
.freeze-table td:last-child {
    position: sticky;
    right: 0;
    width: var(--freeze-action);
    min-width: var(--freeze-action);
    max-width: var(--freeze-action);
    z-index: 3;
    background: #fff;
    box-shadow: -6px 0 8px -8px rgba(0,0,0,0.35);
}
.freeze-table thead th:nth-child(1),
.freeze-table thead th:nth-child(2),
.freeze-table thead th:last-child {
    z-index: 5;
    background: #fafafa;
}
.freeze-table tbody tr:hover td:nth-child(1),
.freeze-table tbody tr:hover td:nth-child(2),
.freeze-table tbody tr:hover td:last-child {
    background: #fafafa;
}

/* Pagination */
.pagination { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; }
.pagination-info { color: #999; font-size: 13px; }
.pagination-btns { display: flex; gap: 4px; }
.pagination-btns .btn { min-width: 32px; padding: 4px 8px; text-align: center; font-size: 13px; }
.pagination-btns .btn.active { background: #1890ff; border-color: #1890ff; color: #fff; }
.pagination-btns .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Search bar */
.search-bar { padding: 16px 20px; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; border-bottom: 1px solid #f0f0f0; }
.search-bar .form-group { margin-bottom: 0; }
.search-bar .form-group label { font-size: 13px; margin-bottom: 4px; }
.search-bar .form-control { height: 34px; }
.search-bar .btn { height: 34px; }

/* Modal */
.modal-mask { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.45); z-index: 1000; justify-content: center; align-items: center; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 6px; width: 520px; max-height: 80vh; overflow-y: auto; box-shadow: 0 6px 16px rgba(0,0,0,0.15); }
.modal-header { padding: 16px 24px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; cursor: move; }
.modal-header h3 { font-size: 16px; font-weight: 500; }
.modal-close { cursor: pointer; font-size: 20px; color: #999; background: none; border: none; line-height: 1; }
.modal-close:hover { color: #333; }
.modal-body { padding: 24px; }
.modal-footer { padding: 12px 24px; border-top: 1px solid #f0f0f0; text-align: right; display: flex; gap: 8px; justify-content: flex-end; }

/* Badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.badge-success { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.badge-danger { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }

/* Toast */
.toast { position: fixed; top: 24px; right: 24px; z-index: 2000; padding: 12px 20px; border-radius: 4px; color: #fff; font-size: 14px; opacity: 0; transition: opacity .3s; }
.toast.show { opacity: 1; }
.toast-success { background: #52c41a; }
.toast-error { background: #ff4d4f; }
.toast-info { background: #1890ff; }

/* Upload loading */
.upload-loading-mask { display: none; position: fixed; inset: 0; z-index: 2500; background: rgba(0,0,0,0.28); align-items: center; justify-content: center; }
.upload-loading-mask.show { display: flex; }
.upload-loading-box { min-width: 160px; padding: 22px 28px; background: #fff; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.16); text-align: center; color: #333; }
.upload-loading-spinner { width: 34px; height: 34px; margin: 0 auto 12px; border: 3px solid #e6f4ff; border-top-color: #1890ff; border-radius: 50%; animation: uploadSpin .8s linear infinite; }
.upload-loading-text { font-size: 14px; }
@keyframes uploadSpin { to { transform: rotate(360deg); } }

/* Inline image upload progress */
.image-upload-progress { margin-top: 6px; display: none; }
.image-upload-progress.show { display: block; }
.image-upload-progress .image-upload-bar { width: 100%; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.image-upload-progress .image-upload-bar-inner { height: 100%; width: 0; background: #1890ff; border-radius: 4px; transition: width .2s; }
.image-upload-progress .image-upload-text { margin-top: 4px; color: #666; font-size: 12px; line-height: 1.4; }
.image-upload-progress.upload-error .image-upload-bar-inner { background: #ff4d4f; }
.image-upload-progress.upload-success .image-upload-bar-inner { background: #52c41a; }
.images-wrap .img-item.uploading { border: 1px dashed #91d5ff; border-radius: 4px; padding: 6px; background: #f6fbff; }
.images-wrap .img-item.uploading .upload-file-name { height: 36px; color: #666; font-size: 12px; line-height: 18px; overflow: hidden; word-break: break-all; display: flex; align-items: center; justify-content: center; text-align: center; }

/* Gallery preview */
.gallery-preview-mask { display: none; position: fixed; inset: 0; z-index: 5000; background: rgba(0,0,0,0.78); align-items: center; justify-content: center; }
.gallery-preview-mask.show { display: flex; }
.gallery-preview-mask img { max-width: 86vw; max-height: 86vh; border-radius: 4px; box-shadow: 0 8px 28px rgba(0,0,0,0.35); }
.gallery-preview-close { position: absolute; top: 18px; right: 28px; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; background: none; border: 0; }
.gallery-preview-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 64px; border: 0; border-radius: 4px; background: rgba(255,255,255,0.18); color: #fff; font-size: 42px; line-height: 1; cursor: pointer; }
.gallery-preview-arrow:hover { background: rgba(255,255,255,0.28); }
.gallery-preview-prev { left: 28px; }
.gallery-preview-next { right: 28px; }
.gallery-preview-count { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); color: #fff; font-size: 13px; background: rgba(0,0,0,0.32); padding: 4px 10px; border-radius: 4px; }
