*,*::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 ── */
#upload-screen{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:20px}
.up-card{background:white;border-radius:20px;padding:52px 44px;text-align:center;width:100%;max-width:400px;box-shadow:0 2px 28px rgba(0,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,.drop-zone.drag{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}

/* ── Main ── */
#main-screen{display:none;height:100vh;min-height:0;overflow:hidden;flex-direction:column;position:relative}
.is-hidden{display:none!important}

/* ── Topbar ── */
.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,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;flex-shrink:0}
.tb-ctrl{display:flex;align-items:center;gap:14px;flex-shrink:0}
.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}
.tab.on{background:white;color:#111827;box-shadow:0 1px 3px rgba(0,0,0,0.1)}
.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,0.2)}
.sw input:checked~.sw-t{background:#6366f1}
.sw input:checked~.sw-t::before{transform:translateX(13px)}
.vsep{width:1px;height:18px;background:#e5e7eb;flex-shrink:0}

/* ── Table tabs ── */
.tablebar{background:white;border-bottom:1px solid #f0f0f0;padding:6px 20px;display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:start;gap:8px 10px;position:sticky;top:52px;z-index:48}
.table-tabs{display:flex;align-items:center;align-content:flex-start;gap:6px;overflow:visible;min-width:0;flex-wrap:wrap;padding-bottom:1px}
.table-tab{display:inline-flex;align-items:center;gap:6px;max-width:220px;height:28px;padding:0 10px;border:1px solid #e5e7eb;border-radius:7px;background:#fafafa;color:#6b7280;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;transition:all .15s}
.table-tab:hover{background:#f3f4f6;color:#374151}
.table-tab.on{background:white;border-color:#c7d2fe;color:#111827;box-shadow:0 1px 3px rgba(99,102,241,.12)}
.table-tab-name{overflow:hidden;text-overflow:ellipsis}
.table-tab-dot{width:6px;height:6px;border-radius:50%;background:#f59e0b;flex-shrink:0}

/* ── Filter bar ── */
.filterbar{background:white;border-bottom:1px solid #f0f0f0;padding:8px 20px;display:flex;align-items:center;justify-content:space-between;gap:14px;position:sticky;top:93px;z-index:45}
.search-box{position:relative;width:min(420px,100%);flex:1;max-width:420px}
.search-mark{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:#9ca3af;font-size:15px;line-height:1;pointer-events:none}
.search-input{width:100%;height:32px;border:1px solid #e5e7eb;border-radius:7px;padding:5px 34px 5px 30px;background:#fafafa;color:#111827;font:inherit;outline:none;transition:all .15s}
.search-input:focus{background:white;border-color:#6366f1;box-shadow:0 0 0 2px rgba(99,102,241,.1)}
.icon-btn{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:22px;height:22px;border:none;border-radius:5px;background:transparent;color:#9ca3af;font-size:16px;line-height:1;cursor:pointer;transition:all .15s}
.icon-btn:hover{background:#f3f4f6;color:#374151}
.filter-stats{display:flex;align-items:center;gap:8px;min-width:0;color:#9ca3af;font-size:11px;white-space:nowrap}
.dirty-count{padding:2px 7px;border-radius:999px;background:#fffbeb;color:#b45309;border:1px solid #fde68a}

/* ── Buttons ── */
.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{background:#4f46e5}
.btn-gho{background:#f3f4f6;color:#374151}.btn-gho:hover{background:#e5e7eb}
.btn-grn{background:#f0fdf4;color:#16a34a}.btn-grn:hover{background:#dcfce7}
.btn-red{background:#fef2f2;color:#dc2626}.btn-red:hover{background:#fee2e2}

/* ── Error banner ── */
.err-banner{background:#fff8f8;border-left:3px solid #f87171;padding:10px 16px;margin:12px 20px 0;border-radius:6px;font-size:12px;color:#b91c1c;display:none;line-height:1.8}

/* ── Table area ── */
.t-area{flex:1;min-height:0;padding:16px 20px;overflow:hidden}
.t-card{height:100%;background:white;border-radius:12px;overflow:hidden;box-shadow:0 1px 6px rgba(0,0,0,0.05)}
.t-scroll{height:100%;overflow:auto}
table{width:100%;border-collapse:separate;border-spacing:0;min-width:max-content;font-size:13px}
thead tr{background:#fafafa;border-bottom:1.5px solid #efefef}
th{height:28px;padding:5px 12px;text-align:left;font-size:11px;font-weight:600;color:#6b7280;letter-spacing:.03em;white-space:nowrap;border-right:1px solid #f5f5f5}
thead th{position:sticky;z-index:10;background:#fafafa;box-shadow:0 1px 0 #efefef}
thead .head-cn th{top:0}
thead .head-en th{top:28px;z-index:9;color:#9ca3af;font-size:10px;font-weight:500;letter-spacing:0}
thead .head-rel th{top:56px;z-index:8;color:#a1a1aa;font-size:10px;font-weight:500;letter-spacing:0;background:#fcfcfd}
thead th.th-rowspan{top:0;z-index:11;height:84px;vertical-align:middle}
th:last-child{border-right:none}
th.th-pk{color:#7c3aed}th.th-ver{color:#0ea5e9}th.th-cmt{color:#9ca3af;font-style:italic}th.th-req::after{content:' *';color:#f87171}
.th-title{display:inline-flex;align-items:center;gap:5px}
.field-id{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;text-transform:none}
.col-badge{font-size:9px;opacity:.6}
.action-th{width:32px}
.rel-empty{color:#d4d4d8}
.rel-link{display:inline-flex;align-items:center;max-width:180px;border:none;background:#eef2ff;color:#4f46e5;border-radius:999px;padding:1px 7px;font:inherit;font-size:10px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.rel-link:hover{background:#e0e7ff;color:#3730a3}
.rel-text{display:inline-block;max-width:180px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#a1a1aa}
tbody tr{border-bottom:1px solid #f9f9f9;transition:background .1s}
tbody tr:hover{background:#fdfdfd}
tbody tr.tr-cmt{background:#fefefe}
tbody tr.tr-cmt td{color:#b0b8c8;font-size:12px}
tbody tr.tr-new{background:#f8fbff}
td{padding:7px 12px;color:#374151;vertical-align:middle;border-right:1px solid #f9f9f9;overflow:visible}
td:last-child{border-right:none}
td.td-pk{color:#7c3aed;font-weight:600;font-size:12px}td.td-ver{color:#0ea5e9;font-size:11px}td.td-cmt{color:#9ca3af}
td.td-chg{background:#fffbea}
.cell-nil{color:#d1d5db}
.row-ind{width:32px;text-align:center;padding:7px 6px !important;color:#d1d5db;font-size:10px}
.row-action{text-align:center;padding:4px 2px}
.row-del{background:none;border:none;cursor:pointer;color:#e0e0e0;font-size:14px;width:24px;height:24px;border-radius:4px;transition:all .15s;display:inline-flex;align-items:center;justify-content:center}
.row-del:hover{background:#fee2e2;color:#ef4444}
.cmt-tag{display:inline-block;padding:1px 5px;border-radius:3px;font-size:9px;background:#f0f0f0;color:#9ca3af}

/* ── Tooltip ── */
.with-tip{display:inline-flex;align-items:center;gap:5px;position:relative}

.tip-btn{
  display:inline-flex;align-items:center;justify-content:center;
  width:16px;height:16px;border-radius:50%;
  border:none;
  background:#ede9fe;color:#7c3aed;
  font-size:10px;font-weight:700;
  cursor:help;flex-shrink:0;
  position:relative;
  transition:background .15s;
}
.tip-btn:hover{background:#ddd6fe}
.field-tip{vertical-align:middle}

.tip-layer{
  position:fixed;
  z-index:9999;
  width:max-content;
  max-width:360px;
  background:#1f2937;
  color:#f9fafb;
  padding:7px 11px;
  border-radius:8px;
  font-size:12px;
  font-style:normal;
  font-weight:400;
  line-height:1.6;
  text-align:left;
  pointer-events:none;
  white-space:normal;
  overflow-wrap:break-word;
  word-break:break-word;
  box-shadow:0 6px 20px rgba(0,0,0,.18);
}

/* ── Edit inputs ── */
.cell-edit{display:flex;flex-direction:column;gap:3px}
.c-inp{border:1px solid #e5e7eb;border-radius:5px;padding:4px 8px;font-size:12px;font-family:inherit;color:#1a1a2e;background:white;min-width:70px;width:100%;outline:none;transition:border-color .15s}
.c-inp:focus{border-color:#6366f1;box-shadow:0 0 0 2px rgba(99,102,241,.1)}
.c-inp.is-dirty{border-color:#fbbf24;background:#fffbeb}
.c-inp.is-dirty:focus{border-color:#f59e0b;box-shadow:0 0 0 2px rgba(245,158,11,.14)}
.c-inp.err{border-color:#f87171;background:#fff8f8}
.c-inp.tip-inp{font-size:11px;color:#9ca3af;border-color:#f3f4f6;background:#fafafa}
.c-inp.tip-inp:focus{color:#374151;border-color:#c7d2fe;background:white}
.c-err{font-size:10px;color:#ef4444;line-height:1.3}

/* ── Bottom bar ── */
.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}
.status-txt{font-size:11px;color:#9ca3af}

/* ── Drop overlay ── */
.drop-overlay{position:absolute;inset:0;z-index:80;background:rgba(240,242,245,.74);backdrop-filter:blur(2px);display:flex;align-items:center;justify-content:center;padding:20px}
.drop-overlay-box{border:2px dashed #818cf8;border-radius:14px;background:white;box-shadow:0 8px 30px rgba(0,0,0,.12);padding:30px 36px;text-align:center;color:#111827}
.drop-overlay-box strong{display:block;font-size:18px;margin-bottom:6px}
.drop-overlay-box span{font-size:12px;color:#9ca3af}

/* ── Modal ── */
.modal-layer{position:fixed;inset:0;z-index:120;background:rgba(17,24,39,.32);display:flex;align-items:center;justify-content:center;padding:18px}
.modal-card{width:min(520px,100%);background:white;border-radius:12px;box-shadow:0 18px 50px rgba(0,0,0,.18);padding:18px}
.modal-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}
.modal-head strong{font-size:15px;color:#111827}
.modal-x{width:26px;height:26px;border:none;border-radius:6px;background:transparent;color:#9ca3af;font-size:20px;line-height:1;cursor:pointer}
.modal-x:hover{background:#f3f4f6;color:#374151}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.f-row{display:flex;flex-direction:column;gap:5px;min-width:0}
.f-row span,.ck-row span{font-size:12px;color:#6b7280}
.span-2{grid-column:1/-1}
.f-inp{height:32px;border:1px solid #e5e7eb;border-radius:7px;padding:5px 9px;background:#fafafa;color:#111827;font:inherit;outline:none;min-width:0}
.f-inp:focus{background:white;border-color:#6366f1;box-shadow:0 0 0 2px rgba(99,102,241,.1)}
.ck-row{display:flex;align-items:center;gap:7px;min-height:24px;color:#6b7280}
.ck-row input{width:14px;height:14px;accent-color:#6366f1}
.modal-err{min-height:18px;margin-top:10px;color:#dc2626;font-size:12px}
.modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:8px}

/* ── Empty state ── */
.empty-st{text-align:center;padding:48px 20px;color:#9ca3af;font-size:13px}

@media(max-width:640px){
  .topbar{padding:0 12px;gap:8px}
  .tablebar{top:52px;padding:6px 12px}
  .table-tab{max-width:170px}
  .filterbar{top:93px;padding:8px 12px;align-items:flex-start;flex-direction:column;gap:6px}
  .search-box{max-width:none}
  .tb-sub{display:none}
  .t-area{padding:12px}
  .up-card{padding:32px 20px}
  .tb-ctrl{gap:8px}
  .vsep{display:none}
  .form-grid{grid-template-columns:1fr}
  .span-2{grid-column:auto}
}
