*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Hiragino Sans GB','Microsoft YaHei',sans-serif;background:#f0f2f5;color:#1a1a2e;font-size:13px;line-height:1.5;min-height:100vh}
#upload-screen{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:20px}
#main-screen{display:none;height:100vh;min-height:0;overflow:hidden;flex-direction:column}

.up-card{background:white;border-radius:20px;padding:52px 44px;text-align:center;width:100%;max-width:440px;box-shadow:0 2px 28px rgba(0,0,0,.08)}
.up-icon{font-size:42px;margin-bottom:16px}
.up-card h1{font-size:22px;font-weight:700;color:#111827;margin-bottom:8px}
.up-card>p{color:#9ca3af;font-size:13px;margin-bottom:28px}
.drop-zone{border:2px dashed #e5e7eb;border-radius:12px;padding:36px 20px;cursor:pointer;transition:all .2s;position:relative}
.drop-zone:hover,.upload-section.dragover .drop-zone{border-color:#818cf8;background:#f5f3ff}
.drop-zone input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}
.drop-zone p{color:#6b7280;font-size:13px;pointer-events:none}
.drop-zone p span{color:#6366f1;font-weight:600}
.drop-zone small{color:#b0b8c8;font-size:11px;margin-top:4px;display:block}
.upload-btn{margin-top:14px}
.loader{display:none;width:28px;height:28px;border:4px solid #f3f4f6;border-top-color:#6366f1;border-radius:50%;animation:spin 1s linear infinite;margin:14px auto 0}
@keyframes spin{to{transform:rotate(360deg)}}

.topbar{background:white;border-bottom:1px solid #f0f0f0;padding:0 20px;height:52px;display:flex;align-items:center;gap:16px;position:sticky;top:0;z-index:50;box-shadow:0 1px 6px rgba(0,0,0,.04)}
.tb-info{flex:1;min-width:0;display:flex;align-items:baseline;gap:10px}
.tb-title{font-size:14px;font-weight:600;color:#111827;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tb-sub{font-size:11px;color:#9ca3af;white-space:nowrap}
.tb-ctrl{display:flex;align-items:center;gap:14px;flex-shrink:0}
.sw-wrap{display:flex;align-items:center;gap:5px;font-size:12px;color:#6b7280;cursor:pointer;user-select:none}
.sw{position:relative;width:30px;height:17px}
.sw input{opacity:0;width:0;height:0;position:absolute}
.sw-t{position:absolute;inset:0;background:#d1d5db;border-radius:17px;transition:.2s;cursor:pointer}
.sw-t::before{content:'';position:absolute;width:13px;height:13px;left:2px;top:2px;background:white;border-radius:50%;transition:.2s;box-shadow:0 1px 2px rgba(0,0,0,.2)}
.sw input:checked~.sw-t{background:#6366f1}
.sw input:checked~.sw-t::before{transform:translateX(13px)}

.tablebar{background:white;border-bottom:1px solid #f0f0f0;padding:6px 20px;display:flex;align-items:center;justify-content:space-between;gap:10px;position:sticky;top:52px;z-index:48}
.mode-tabs{background:#f3f4f6;border-radius:8px;padding:2px;display:flex;gap:1px}
.tab{padding:4px 14px;border-radius:6px;font-size:12px;font-weight:500;border:none;background:transparent;color:#6b7280;cursor:pointer;transition:all .15s;display:inline-flex;align-items:center;gap:6px}
.tab input{position:absolute;opacity:0;pointer-events:none}
.tab.selected{background:white;color:#111827;box-shadow:0 1px 3px rgba(0,0,0,.1)}

.workspace{flex:1;min-height:0;display:grid;grid-template-columns:300px minmax(0,1fr);gap:16px;padding:16px 20px;overflow:hidden}
.side-panel,.content-panel{min-height:0;overflow:auto}
.panel-block,.preview-section,.debug-info,.warning-container,.error-container,.success-container{background:white;border-radius:12px;box-shadow:0 1px 6px rgba(0,0,0,.05)}
.panel-block{padding:14px;margin-bottom:12px}
.panel-block h2,.section-head h2{font-size:14px;font-weight:600;color:#111827}
.section-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;margin-bottom:12px}
.section-head span,.storage-info,.config-description{font-size:11px;color:#9ca3af}
label{display:inline-flex;align-items:center;gap:7px;color:#374151;cursor:pointer}
input[type="checkbox"],input[type="radio"]{accent-color:#6366f1}

.file-list{display:flex;flex-direction:column;gap:8px}
.file-item{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:9px 10px;border:1px solid #f0f0f0;border-radius:8px;background:#fafafa}
.file-item>div{display:flex;align-items:center;gap:8px;min-width:0}
.file-item>div:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.status{width:8px;height:8px;border-radius:50%;display:inline-block;flex-shrink:0}
.status.pending{background:#f59e0b}.status.success{background:#16a34a}.status.error{background:#ef4444}
.message{font-size:11px;color:#9ca3af;white-space:nowrap}
.remove-btn{width:24px;height:24px;border:none;border-radius:5px;background:transparent;color:#9ca3af;font-size:18px;line-height:1;cursor:pointer}
.remove-btn:hover{background:#fee2e2;color:#ef4444}

.json-config{display:none}
.json-config.show{display:block}
.json-config label,.config-controls label{display:flex;margin-bottom:9px}
.config-controls{display:flex;flex-direction:column;align-items:flex-start;gap:6px;margin-bottom:10px}
#config-rows-list{display:flex;flex-wrap:wrap;gap:8px}
.config-row-item{display:inline-flex;align-items:center;gap:6px;border:1px solid #e5e7eb;border-radius:7px;background:#fafafa;padding:6px 9px;font-size:12px}
.config-row-name{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;color:#374151}
.no-config-rows{color:#9ca3af;font-size:12px}

#export-config-section,#preview-section{display:none}
.warning-container,.error-container,.success-container{display:none;padding:12px 16px;margin-bottom:12px;line-height:1.7}
.warning-container{background:#fffbeb;color:#92400e;border-left:3px solid #f59e0b}
.error-container{background:#fff8f8;color:#b91c1c;border-left:3px solid #f87171}
.success-container{background:#f0fdf4;color:#166534;border-left:3px solid #22c55e}
.error-list{margin-top:6px;max-height:220px;overflow:auto}
.preview-section{padding:14px;height:auto;min-height:260px}
.debug-info{display:none;padding:14px;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;white-space:pre-wrap;color:#6b7280;font-size:12px}

.file-tabs{display:flex;gap:6px;overflow:auto;margin-bottom:12px;padding-bottom:1px}
.file-tab{height:28px;display:inline-flex;align-items:center;max-width:220px;padding:0 10px;border:1px solid #e5e7eb;border-radius:7px;background:#fafafa;color:#6b7280;font-size:12px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.file-tab:hover{background:#f3f4f6;color:#374151}
.file-tab.active{background:white;border-color:#c7d2fe;color:#111827;box-shadow:0 1px 3px rgba(99,102,241,.12)}
.table-container{overflow:auto;background:white;border-radius:12px;border:1px solid #f0f0f0;max-height:calc(100vh - 230px)}
table{width:100%;border-collapse:separate;border-spacing:0;min-width:max-content;font-size:13px}
thead tr{background:#fafafa}
th{position:sticky;top:0;z-index:5;background:#fafafa;padding:9px 12px;text-align:left;font-size:11px;font-weight:600;color:#6b7280;white-space:nowrap;border-right:1px solid #f5f5f5;box-shadow:0 1px 0 #efefef}
td{padding:7px 12px;color:#374151;border-right:1px solid #f9f9f9;border-bottom:1px solid #f9f9f9;vertical-align:top}
th:last-child,td:last-child{border-right:none}
tbody tr:hover{background:#fdfdfd}
.required-mark{color:#f87171;font-weight:700}
.pk-mark{color:#7c3aed;font-weight:700}
details{margin-top:10px}
summary{cursor:pointer;font-weight:600;color:#374151;margin-bottom:8px}

.btn{padding:5px 13px;border-radius:7px;font-size:12px;font-weight:500;border:none;cursor:pointer;transition:all .15s;white-space:nowrap}
.btn:disabled{opacity:.55;cursor:not-allowed}
.btn-pri{background:#6366f1;color:white}.btn-pri:hover:not(:disabled){background:#4f46e5}
.btn-gho{background:#f3f4f6;color:#374151}.btn-gho:hover:not(:disabled){background:#e5e7eb}
.bbar{background:white;border-top:1px solid #f0f0f0;padding:10px 20px;display:flex;align-items:center;justify-content:space-between;gap:12px;position:sticky;bottom:0;flex-shrink:0}
.bbar-l,.bbar-r{display:flex;align-items:center;gap:8px}

@media(max-width:820px){
  .topbar{height:auto;min-height:52px;padding:10px 12px;align-items:flex-start;flex-direction:column}
  .tb-ctrl{flex-wrap:wrap}
  .tablebar{top:0;padding:6px 12px}
  .workspace{grid-template-columns:1fr;padding:12px;overflow:auto}
  .side-panel,.content-panel{overflow:visible}
  #main-screen{overflow:auto;height:auto;min-height:100vh}
  .table-container{max-height:none}
  .up-card{padding:32px 20px}
  .bbar{padding:10px 12px}
}
