/* ============== 全局样式 ============== */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f3f4f6;
    --bg-dark: #1f2937;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-sm: 4px;
}

* {
    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: var(--text-color);
    background: var(--bg-color);
    line-height: 1.5;
}

/* ============== 布局 ============== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============== 顶部工具栏 ============== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-dark);
    color: white;
    box-shadow: var(--shadow);
    z-index: 100;
}

.toolbar-title {
    font-size: 16px;
    font-weight: 600;
}

.toolbar-left {
    display: flex;
    align-items: center;
}

.toolbar-buttons {
    display: flex;
    gap: 8px;
}

/* ============== 主内容区 ============== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============== 侧边栏 ============== */
.sidebar {
    width: 240px;
    background: white;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
}

.sidebar-new-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    background: #f8faff;
}

.structure-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.structure-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.structure-item:hover {
    background: #f9fafb;
}

.structure-item.active {
    background: #eff6ff;
    color: var(--primary-color);
}

.structure-item .icon {
    font-size: 16px;
}

.structure-item .name {
    flex: 1;
}

.structure-del-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.structure-item:hover .structure-del-btn {
    opacity: 1;
}

.structure-del-btn:hover {
    color: var(--danger-color);
    background: #fee2e2;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

/* ============== 内容区 ============== */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-color);
}

/* ============== Tab导航 ============== */
.tab-nav {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* ============== Tab内容 ============== */
.tab-content {
    flex: 1;
    overflow: hidden;
}

.tab-panel {
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.tab-panel.active {
    display: flex;
}

.tab-panel.active {
    display: flex;
}

/* ============== 面板头部 ============== */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============== 面板内容 ============== */
.panel-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

/* ============== 按钮 ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger-color);
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-secondary {
    background: #e5e7eb;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-link {
    background: transparent;
    color: var(--primary-color);
    padding: 4px 8px;
}

.btn-link:hover {
    background: #eff6ff;
}

.btn-large {
    padding: 10px 20px;
    font-size: 14px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* ============== 表单 ============== */
.form-group {
    margin-bottom: 16px;
}

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

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
}

.form-group input[type="date"] {
    height: 36px;
}

/* ============== 表格 ============== */
.fields-table-container,
.records-table-container {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.fields-table-container {
    overflow: auto;
    max-height: calc(100vh - 470px);
}

.records-table-container {
    overflow: auto;
    max-height: calc(100vh - 350px);
}

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

.fields-table th,
.fields-table td,
.records-table th,
.records-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.fields-table th,
.records-table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 13px;
}

.fields-table tbody tr:hover,
.records-table tbody tr:hover {
    background: #f9fafb;
}

/* ============== 字段操作 ============== */
.field-actions button {
    padding: 4px 8px;
    margin-right: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.field-actions button:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.field-actions button.delete:hover {
    background: #fee2e2;
    color: var(--danger-color);
}

/* ============== 模板布局 ============== */
.template-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 400px;
}

.template-list-container {
    flex: 0 0 220px;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.template-list {
    padding: 8px;
    flex: 1;
}

.template-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.template-item:hover {
    background: #f9fafb;
}

.template-item.active {
    background: #eff6ff;
    color: var(--primary-color);
}

.template-content {
    flex: 1;
    background: white;
    border-radius: var(--radius);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    overflow: auto;
    max-height: calc(100vh - 220px);
}
}

.template-content .empty-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    font-size: 14px;
}

.template-list-container .empty-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 16px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.template-card-title {
    padding: 12px 16px;
    font-weight: bold;
    font-size: 14px;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
    flex-shrink: 0;
}

.template-content .template-card-title {
    background: transparent;
    padding-bottom: 8px;
    font-size: 15px;
}

.template-form-wrapper {
    padding: 16px 20px;
    overflow-y: auto;
}

.template-form-row {
    display: flex;
    gap: 24px;
}

.template-form-col {
    flex: 1;
}

.template-form-col .form-group {
    margin-bottom: 16px;
}
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.entry-images {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow);
}

.entry-images h4 {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
}

.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background: #f8faff;
}

.image-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.image-placeholder {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.image-upload-box {
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 8px;
}

.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background: #f8faff;
}

.image-item {
    position: relative;
    width: 80px;
    height: 80px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-item .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.entry-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

/* ============== 查询栏 ============== */
.query-bar {
    background: white;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    overflow: auto;
    max-height: calc(100vh - 320px);
}
    box-shadow: var(--shadow);
}

.query-bar .form-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.query-bar .form-group label {
    width: auto;
    margin-right: 0;
    margin-bottom: 0;
    white-space: nowrap;
    font-size: 13px;
}

.query-bar .form-group input[type="text"],
.query-bar .form-group input[type="date"],
.query-bar .form-group select {
    width: auto;
    min-width: 120px;
    padding: 6px 10px;
    font-size: 13px;
}

.query-bar .form-group input[type="date"] {
    height: auto;
}

.query-bar .btn {
    padding: 6px 14px;
    font-size: 13px;
}

.records-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.records-stats {
    color: var(--text-muted);
    font-size: 13px;
}

/* ============== 数据录入美化 ============== */
.entry-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.entry-template-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 400px;
}

.entry-template-list {
    flex: 0 0 200px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.entry-template-list .template-list {
    flex: 1;
    overflow-y: auto;
}

.entry-template-list .empty-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.entry-form-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.entry-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: auto;
    max-height: calc(100vh - 220px);
}

.entry-empty {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 60px 20px;
    text-align: center;
}

.entry-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.entry-empty-text {
    font-size: 16px;
    color: var(--text-color);
    font-weight: 500;
    margin-bottom: 8px;
}

.entry-empty-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.entry-form-row {
    display: flex;
    gap: 24px;
}

.entry-form-col {
    flex: 1;
    padding: 24px;
}

.entry-form-col .form-group {
    margin-bottom: 20px;
}

.entry-form-col .form-group:last-child {
    margin-bottom: 0;
}

.entry-form {
    padding: 0;
}

.entry-form .form-group {
    margin-bottom: 20px;
}

.entry-form .form-group:last-child {
    margin-bottom: 0;
}

.entry-form .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-color);
}

.entry-form .form-group label.required::before {
    content: '*';
    color: var(--danger-color);
    margin-right: 4px;
}

.entry-form input[type="text"],
.entry-form input[type="number"],
.entry-form input[type="date"],
.entry-form select,
.entry-form textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    background: #fafafa;
}

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

.entry-images {
    background: white;
    padding: 20px 32px;
    border-top: 1px solid var(--border-color);
}

.entry-images h4 {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
}

.entry-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding: 16px 20px;
    justify-content: flex-end;
    border-top: 1px solid var(--border-color);
}

.entry-actions .btn {
    min-width: 120px;
}

/* ============== 导出表单 ============== */
.export-form {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    overflow: auto;
    max-height: calc(100vh - 180px);
}

.export-form .form-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.export-form .form-group > label {
    width: 100px;
    text-align: right;
    margin-right: 12px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-group label,
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
}

.checkbox-group,
.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range-inputs input {
    width: 140px;
}

.export-actions {
    margin-top: 24px;
    padding-left: 112px;
}

/* ============== 状态栏 ============== */
.statusbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: #f9fafb;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.status-item {
    margin-right: 24px;
}

/* ============== 模态框 ============== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

/* 下拉选项输入 */
.option-item {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.option-item .option-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.option-add, .option-del {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.option-add {
    background: #e8f5e9;
    color: #2e7d32;
}

.option-add:hover {
    background: #c8e6c9;
}

.option-del {
    background: #ffebee;
    color: #c62828;
}

.option-del:hover {
    background: #ffcdd2;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body select,
.modal-body textarea {
    padding: 8px 12px;
    height: 36px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============== Toast ============== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success { background: var(--success-color); }
.toast.error { background: var(--danger-color); }
.toast.warning { background: var(--warning-color); }
.toast.info { background: var(--primary-color); }

/* ============== 图片预览 ============== */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1500;
    display: none;
    align-items: center;
    justify-content: center;
}

.image-preview.active {
    display: flex;
}

.image-preview-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.image-preview-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.image-preview-close {
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 28px;
    color: #fff;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transition: background 0.2s;
}

.image-preview-close:hover {
    background: rgba(255,255,255,0.3);
}

.image-preview-nav {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.image-preview-nav button {
    color: #fff;
    border-color: #fff;
}

/* ============== 空状态 ============== */
.empty-tip {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 13px;
}

/* ============== 分页 ============== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
}

.pagination .page-info {
    margin: 0 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ============== 结构信息 ============== */
.structure-info {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    gap: 24px;
    max-height: calc(100vh - 380px);
    overflow: auto;
    align-items: center;
    box-shadow: var(--shadow);
}

.structure-info .form-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

.structure-info .form-group label {
    margin-bottom: 0;
    white-space: nowrap;
}

.structure-info .form-group input {
    width: auto;
    min-width: 200px;
}

/* ============== 单元格预览 ============== */
.cell-preview-container {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.cell-preview-header {
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--text-color);
    font-size: 14px;
}

.cell-preview-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: fit-content;
}

.cell-preview-row {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.cell-preview-row:first-child .cell-preview-cell {
    background: #f5f5f5;
    font-weight: bold;
}

.cell-preview-cell {
    border-right: 1px solid #e0e0e0;
    border-left: 1px solid #e0e0e0;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-preview-cell:first-child {
    border-left: 1px solid #e0e0e0;
}

/* ============== 模板选择器 ============== */
.template-selector {
    position: relative;
}

.template-selector select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    background: white;
    cursor: pointer;
    appearance: none;
    min-width: 150px;
}

.template-selector::after {
    content: '▼';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

/* ============== 拖拽 ============== */
.drag-over {
    border-color: var(--primary-color) !important;
    background: #eff6ff !important;
}

/* ============== 动画 ============== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ============== 滚动条 ============== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ============== 复选框 ============== */
input[type="checkbox"] {
    margin-right: 6px;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ============== 右键菜单 ============== */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 140px;
    overflow: hidden;
}

.context-menu div {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.context-menu div:hover {
    background: #f9fafb;
}

.context-menu div.danger {
    color: var(--danger-color);
}

.context-menu div.danger:hover {
    background: #fee2e2;
}

/* ============== 响应式 ============== */
@media (max-width: 900px) {
    /* 主布局切换为纵向 */
    .main-content {
        flex-direction: column;
    }

    /* 侧边栏改为可隐藏的悬浮抽屉 */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 12px rgba(0,0,0,0.15);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* 侧边栏遮罩 */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    /* 移动端菜单按钮 */
    .mobile-menu-btn {
        display: flex !important;
    }

    /* 汉堡菜单图标 */
    .hamburger {
        display: inline-block;
        width: 20px;
        height: 14px;
        position: relative;
        cursor: pointer;
    }

    .hamburger::before,
    .hamburger::after,
    .hamburger span {
        content: '';
        position: absolute;
        left: 0;
        width: 100%;
        height: 2px;
        background: white;
        transition: all 0.3s ease;
    }

    .hamburger::before { top: 0; }
    .hamburger::after { bottom: 0; }
    .hamburger span { top: 50%; transform: translateY(-50%); }

    .sidebar.open .hamburger::before { top: 50%; transform: translateY(-50%) rotate(45deg); }
    .sidebar.open .hamburger::after { bottom: 50%; transform: translateY(50%) rotate(-45deg); }
    .sidebar.open .hamburger span { opacity: 0; }

    /* 内容区全宽 */
    .content {
        width: 100%;
        min-width: unset;
    }

    /* Tab导航横向滚动 */
    .tab-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tab-nav::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex-shrink: 0;
        padding: 12px 16px;
    }

    /* 录入表单单列布局 */
    .entry-template-layout {
        flex-direction: column;
    }

    .entry-template-list {
        width: 100%;
        flex: none;
        min-height: auto;
        max-height: 150px;
    }

    .entry-form-row {
        flex-direction: column;
        gap: 0;
    }

    .entry-form-col {
        padding: 16px;
    }

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

    /* 模板管理单列 */
    .template-layout {
        flex-direction: column;
    }

    .template-list-container {
        width: 100%;
        flex: none;
        min-height: auto;
        max-height: 150px;
    }

    /* 查询栏单行换行 */
    .query-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .query-bar .form-group {
        flex-wrap: wrap;
    }

    .query-bar .form-group input[type="text"],
    .query-bar .form-group input[type="date"],
    .query-bar .form-group select {
        width: 100%;
        min-width: unset;
    }

    /* 导出表单单列 */
    .export-form .form-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .export-form .form-group > label {
        width: auto;
        text-align: left;
        margin-right: 0;
        margin-bottom: 8px;
    }

    .export-actions {
        padding-left: 0;
    }

    /* 状态栏换行 */
    .statusbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .status-item {
        margin-right: 0;
        flex: 1 1 45%;
    }

    /* 面板响应式 */
    .panel-body {
        padding: 12px;
    }

    /* 结构信息单列 */
    .structure-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .structure-info .form-group {
        flex-wrap: wrap;
    }

    .structure-info .form-group input {
        width: 100%;
        min-width: unset;
    }

    /* 表格横向滚动 */
    .fields-table-container,
    .records-table-container {
        overflow-x: auto;
        max-height: calc(100vh - 280px);
    }

    .fields-table,
    .records-table {
        min-width: 600px;
    }

    /* 模态框全宽 */
    .modal-content {
        width: 95%;
        max-width: none;
        max-height: 85vh;
    }

    /* Toast右下角 */
    .toast-container {
        left: 20px;
        right: 20px;
    }

    /* 图片预览全屏 */
    .image-preview-content {
        width: 95vw;
        height: 90vh;
    }

    .image-preview-content img {
        max-width: 95vw;
        max-height: 75vh;
    }
}

@media (max-width: 600px) {
    /* 整体高度使用 dvh 适配移动端地址栏 */
    .app-container {
        height: 100dvh;
    }

    /* 工具栏进一步简化 */
    .toolbar {
        padding: 10px 12px;
    }

    .toolbar-title {
        font-size: 14px;
    }

    .toolbar-buttons {
        gap: 4px;
    }

    .toolbar-buttons .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Tab文字简化 */
    .tab-btn {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* 按钮尺寸调整 */
    .btn-large {
        padding: 10px 16px;
        font-size: 14px;
    }

    .entry-actions .btn {
        min-width: 100px;
        flex: 1;
    }

    /* 表头行高调低 */
    .cell-preview-row {
        min-height: 40px;
    }

    /* 分页简化 */
    .pagination {
        flex-wrap: wrap;
    }

    .pagination .page-info {
        width: 100%;
        text-align: center;
        margin: 8px 0;
    }

    /* 字段表格手机端高度 */
    .fields-table-container {
        max-height: calc(100vh - 680px);
    }

    /* 记录表格手机端高度 */
    .records-table-container {
        max-height: calc(100vh - 650px);
    }

    /* 录入表单卡片手机端高度 */
    .entry-card {
        max-height: calc(100vh - 400px);
    }

    /* 模板卡片手机端高度 */
    .template-content {
        max-height: calc(100vh - 400px);
    }
}

/* ============== 工具类 ============== */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-small {
    font-size: 12px;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

/* ============== 图片上传控件 ============== */
.image-upload-container {
    margin-bottom: 16px;
}

.image-upload-container .image-upload-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    background: #fafafa;
}

.image-upload-container .image-upload-box:hover {
    border-color: var(--primary-color);
    background: #f8faff;
}

.image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fafafa;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.image-preview-item .remove-btn:hover {
    background: rgba(239, 68, 68, 0.8);
}

.image-upload-placeholder {
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 0;
}

/* 记录表格中的图片缩略图 */
.record-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    margin-right: 4px;
    transition: border-color 0.2s;
}

.record-thumb:hover {
    border-color: var(--primary-color);
}

.record-thumb-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
}
