/* 跨境合规通 — 苹果极简风格 */
:root{
  --accent:#0071e3;
  --bg:#f5f5f7;
  --card:#ffffff;
  --card-2:#fbfbfd;
  --text:#1d1d1f;
  --sub:#6e6e73;
  --line:#d2d2d7;
  --line-soft:#e8e8ed;
  --shadow:0 1px 3px rgba(0,0,0,.06),0 10px 30px rgba(0,0,0,.05);
  --radius:14px;
}
body.theme-dark{
  --bg:#1c1c1e;
  --card:#2c2c2e;
  --card-2:#323234;
  --text:#f5f5f7;
  --sub:#98989d;
  --line:#3a3a3c;
  --line-soft:#444446;
  --shadow:0 1px 3px rgba(0,0,0,.4),0 10px 30px rgba(0,0,0,.35);
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue","PingFang SC","Microsoft YaHei",sans-serif;
  background:var(--bg); color:var(--text);
  -webkit-font-smoothing:antialiased; font-size:14px;
}

/* 顶栏 */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 20px; background:var(--card); border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:20;
}
.brand{display:flex; align-items:center; gap:9px; font-size:17px; font-weight:600; letter-spacing:.3px;}
.brand-dot{width:11px; height:11px; border-radius:50%; background:var(--accent); box-shadow:0 0 0 4px color-mix(in srgb,var(--accent) 22%,transparent);}
.tools{display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
.tool-group{display:flex; align-items:center; gap:6px;}
.tool-label{font-size:12px; color:var(--sub);}
#customsMethod{
  appearance:none; border:1px solid var(--line); background:var(--card-2); color:var(--text);
  padding:7px 10px; border-radius:10px; font-size:13px; cursor:pointer;
}
#accentPicker{width:30px; height:30px; border:none; background:none; cursor:pointer; padding:0;}
.sep{width:1px; height:22px; background:var(--line); margin:0 2px;}
.tbtn{
  border:1px solid var(--line); background:var(--card-2); color:var(--text);
  padding:8px 14px; border-radius:10px; font-size:13px; cursor:pointer; transition:.15s;
}
.tbtn:hover{border-color:var(--accent);}
.tbtn.primary{background:var(--accent); color:#fff; border-color:var(--accent);}
.tbtn.primary:hover{filter:brightness(1.05);}
.tbtn.block{width:100%; margin-top:6px; padding:11px;}

/* 布局 */
.layout{display:flex; height:calc(100vh - 53px);}
.sidebar{
  width:210px; flex:none; background:var(--card); border-right:1px solid var(--line);
  padding:18px 14px; display:flex; flex-direction:column; gap:10px;
}
.sidetitle{font-size:12px; color:var(--sub); text-transform:uppercase; letter-spacing:.6px; padding-left:6px;}
.doc-tabs{display:flex; flex-direction:column; gap:4px;}
.doc-tab{
  text-align:left; border:none; background:transparent; color:var(--text);
  padding:11px 14px; border-radius:10px; font-size:14px; cursor:pointer; transition:.15s;
}
.doc-tab:hover{background:var(--card-2);}
.doc-tab.active{background:color-mix(in srgb,var(--accent) 14%,transparent); color:var(--accent); font-weight:600;}
.shared-btn{
  margin-top:6px; border:1px dashed var(--line); background:var(--card-2); color:var(--text);
  padding:11px; border-radius:10px; font-size:13px; cursor:pointer; text-align:center;
}
.shared-btn:hover{border-color:var(--accent);}
.tip{font-size:11px; color:var(--sub); line-height:1.5; margin-top:auto; padding:8px;}
.cs-line{font-size:11px; color:var(--accent); text-align:center; padding:8px 8px 12px; border-top:1px solid var(--line-soft); letter-spacing:.3px;}

.main{flex:1; overflow:auto; padding:26px 30px;}

/* 编辑器 */
.editor-doc{max-width:860px; margin:0 auto;}
.section{
  background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  padding:18px 20px; margin-bottom:16px; box-shadow:var(--shadow);
}
.section-title{font-size:12px; font-weight:600; color:var(--sub); text-transform:uppercase; letter-spacing:.6px; margin-bottom:14px;}
.grid{display:grid; grid-template-columns:repeat(2,1fr); gap:14px 26px;}
.fld{display:flex; flex-direction:column; gap:5px;}
.fld-label{font-size:12px; color:var(--sub);}

/* 买卖方左右分栏 + 色块标记 */
.parties-split{display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:6px;}
.pp-col{border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; background:var(--card);}
.pp-head{padding:11px 16px; font-size:13px; font-weight:700; letter-spacing:.8px; color:#fff;
  -webkit-print-color-adjust:exact; print-color-adjust:exact;}
.pp-head.buyer{background:var(--accent);}
.pp-head.seller{background:#34c759;}
.pp-body{padding:14px; display:grid; gap:12px;}
.pp-meta{margin-top:14px;}

/* 我的企业弹窗：顶部粘贴框 */
.shared-paste{margin-bottom:16px; background:var(--card-2); border:1px solid var(--line); border-radius:var(--radius); padding:12px 14px;}
.paste-box{width:100%; border:1px solid var(--line); border-radius:10px; padding:10px 12px; font-family:inherit; font-size:13px; line-height:1.5; color:var(--text); background:var(--card); resize:vertical; box-sizing:border-box;}
.paste-box:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 18%,transparent);}
.shared-paste .btn-add{margin-top:10px;}
.inp{
  width:100%; border:1px solid var(--line); background:var(--card-2); color:var(--text);
  padding:9px 11px; border-radius:9px; font-size:14px; font-family:inherit; transition:.15s;
}
.inp:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 18%,transparent);}
.inp.ro{background:var(--card); color:var(--sub); cursor:default;}

/* 商品表编辑 */
/* 商品明细表：fixed 布局 + 自动换行，避免长文本重叠 */
.tbl-wrap{overflow-x:auto; margin-top:6px;}
.items{width:100%; border-collapse:collapse; font-size:13px; margin-top:0; table-layout:fixed;}
.items th,.items td{padding:6px 8px; border:1px solid var(--line); text-align:center; vertical-align:middle; word-break:break-word; overflow-wrap:anywhere; box-sizing:border-box;}
.items th{background:var(--card-2); font-weight:600; color:var(--sub); font-size:12px;}
.items td{border-color:var(--line-soft);}
.items .col-name{text-align:left; width:26%;}   /* 商品名称及规格型号：居左、加宽 */
.items .c-idx{width:42px; text-align:center;}
.items .op-col{width:42px; text-align:center;}
.cell{width:100%; box-sizing:border-box; border:1px solid var(--line); background:var(--card-2); color:var(--text); padding:6px 7px; border-radius:6px; font-size:13px; font-family:inherit;}
.cell:focus{outline:none; border-color:var(--accent);}
.col-rm{margin-left:6px; cursor:pointer; color:var(--sub); font-size:11px; vertical-align:middle; font-weight:400;}
.col-rm:hover{color:red;}
.btn-mini{border:none; background:transparent; color:var(--sub); cursor:pointer; font-size:14px; padding:4px 8px; border-radius:8px;}
.btn-mini:hover{background:color-mix(in srgb,red 12%,transparent); color:red;}
.tbl-tools{display:flex; gap:10px; flex-wrap:wrap; margin-top:12px;}
.btn-add{border:1px dashed var(--line); background:var(--card-2); color:var(--accent); padding:9px 16px; border-radius:10px; font-size:13px; cursor:pointer;}
.btn-add:hover{border-color:var(--accent);}
.btn-add.ghost{color:var(--sub);}
.btn-add.ghost:hover{border-color:var(--sub); color:var(--text);}

/* 只读排版（预览/分享/打印） */
.doc-sheet{max-width:860px; margin:18px auto; background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:38px 42px; box-shadow:var(--shadow);}
.doc-head{display:flex; align-items:center; gap:18px; border-bottom:2px solid var(--text); padding-bottom:16px; margin-bottom:20px; min-height:64px;}
.doc-logo-wrap{width:140px; flex:none;}
.doc-logo{max-width:140px; max-height:62px; object-fit:contain;}
.doc-title{font-size:19px; font-weight:600; letter-spacing:.4px;}
.doc-note{background:color-mix(in srgb,#ffcc00 18%,transparent); color:#8a6d00; border-radius:8px; padding:9px 13px; font-size:13px; margin-bottom:16px;}
.doc-body .section{border:none; box-shadow:none; padding:0; margin-bottom:20px; background:transparent;}
.doc-body .fld-label{font-size:11px;}
.doc-body .fld-value{font-size:14px; padding:4px 0; border-bottom:1px solid var(--line); min-height:21px; word-break:break-word;}
.doc-body .grid{gap:10px 26px;}
.doc-foot{margin-top:22px; padding-top:12px; border-top:1px solid var(--line); font-size:11px; color:var(--sub); text-align:center;}
.empty{text-align:center; color:var(--sub); padding:16px;}

/* 签字盖章区 */
.sign-area{margin-top:6px;}
.sign-cols{display:flex; gap:32px;}
.sign-row{display:flex; align-items:flex-end; gap:12px; margin-top:22px; flex:1; min-width:0;}
.sign-label{white-space:nowrap; font-size:14px; font-weight:600; color:var(--text);}
.sign-line{flex:1; border-bottom:1.5px solid var(--text); min-height:24px;}

/* 报关草单编辑态：分组卡片，清晰易填 */
.cg-block{border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; background:var(--card); margin-bottom:16px;}
.cg-block-title{
  font-size:12px; font-weight:600; color:var(--accent);
  background:color-mix(in srgb,var(--accent) 10%,transparent);
  padding:9px 14px; border-bottom:1px solid var(--line); letter-spacing:.3px;
}
.cg-block .cg-grid{grid-template-columns:repeat(2,1fr); gap:13px 20px; padding:14px 16px 16px;}
.cg-wide{grid-column:1 / -1;}

/* 报关草单只读/打印态：类报关单线框 + 分组标题带 */
.customs-sheet{
  display:grid; grid-template-columns:repeat(9, 1fr);
  border:1px solid var(--text); border-right:0; border-bottom:0; margin-bottom:18px; font-size:13px; background:var(--card);
}
.customs-sheet .cs-cap{
  grid-column:1 / -1;
  background:color-mix(in srgb,var(--accent) 12%,transparent); color:var(--accent);
  font-size:12px; font-weight:600; padding:6px 10px;
  border-right:1px solid var(--text); border-bottom:1px solid var(--text);
}
.customs-sheet .cs-label{
  background:var(--card-2); color:var(--sub); font-size:12px; padding:6px 8px;
  border-right:1px solid var(--text); border-bottom:1px solid var(--text);
  display:flex; align-items:center;
}
.customs-sheet .cs-value{
  padding:6px 8px; border-right:1px solid var(--text); border-bottom:1px solid var(--text);
  min-height:28px; word-break:break-word;
}
.customs-sheet .cs-span2{grid-column:span 2;}
.customs-sheet .cs-span8{grid-column:span 8;}
.customs-sheet .cs-l-wide{grid-column-start:1;}

/* 弹窗 */
.modal{position:fixed; inset:0; background:rgba(0,0,0,.4); display:flex; align-items:center; justify-content:center; z-index:50; padding:20px;}
.modal[hidden]{display:none;}
.modal-card{background:var(--bg); border-radius:18px; width:480px; max-width:100%; max-height:88vh; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 20px 60px rgba(0,0,0,.3);}
.modal-card.wide{width:920px;}
.modal-bar{display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid var(--line); font-weight:600; font-size:15px;}
.modal-bar > div{display:flex; gap:8px;}
.modal-body{padding:18px; overflow:auto;}
.modal-body.scroll{max-height:80vh;}
.share-note{font-size:12px; color:var(--sub); line-height:1.6; margin:10px 0;}

/* 打印隔离 */
@media print{
  :root{--text:#1d1d1f;--sub:#6e6e73;--line:#d2d2d7;--card:#fff;}
  body{background:#fff;}
  .topbar,.layout,.modal{display:none !important;}
  #printArea{display:block !important;}
  #printArea .doc-sheet{box-shadow:none; border:none; max-width:none; margin:0; padding:0; border-radius:0;}
  #printArea .doc-head{border-color:#000;}
  #printArea .doc-body .section{background:transparent;}
  #printArea .tbl-wrap{overflow:visible;}
  #printArea .items th,#printArea .items td{border-color:#000;}
}
#printArea{display:none;}

/* 滚动条 */
.main::-webkit-scrollbar,.modal-body::-webkit-scrollbar{width:10px;}
.main::-webkit-scrollbar-thumb,.modal-body::-webkit-scrollbar-thumb{background:var(--line); border-radius:6px;}

@media (max-width:720px){
  .grid{grid-template-columns:1fr;}
  .parties-split{grid-template-columns:1fr;}
  .sign-cols{flex-direction:column; gap:0;}
  .sidebar{width:150px;}
  .doc-sheet{padding:22px;}
}
